Skip to content

feat(mcp): API-key management tools for the stdio MCP server#226

Merged
duyet merged 1 commit into
mainfrom
claude/stdio-mcp-key-tools
Jun 18, 2026
Merged

feat(mcp): API-key management tools for the stdio MCP server#226
duyet merged 1 commit into
mainfrom
claude/stdio-mcp-key-tools

Conversation

@duyet

@duyet duyet commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Adds create_api_key, list_api_keys, and revoke_api_key to the local stdio MCP server (@agentstate/mcp), matching the hosted remote MCP server's key tools. They call the keyless /api/v1/keys endpoints (project from the authenticating key); create_api_key accepts optional scopes and the server enforces the subset-of-caller delegation rule.

  • 3 new tools + apiScopeSchema enum mirroring the API scope taxonomy
  • Tests cover request URL/method/body for each
  • README tool list updated

Verification: tsc --noEmit clean (via node), vitest run 11 passed.

Co-Authored-By: Duyet Le [email protected]
Co-Authored-By: duyetbot [email protected]

Adds create_api_key, list_api_keys, and revoke_api_key tools so MCP clients can
manage project API keys (with scopes) directly — matching the hosted remote MCP
server. They call the keyless /api/v1/keys endpoints (project from the auth
context). create_api_key enforces the subset-of-caller scope rule server-side.

- src/index.ts: 3 new tools + an apiScopeSchema enum of the API scopes
- tests: cover the new tools' request URL/method/body
- README: list the new tools

Co-Authored-By: Duyet Le <[email protected]>
Co-Authored-By: duyetbot <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @duyet, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@duyet, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 28 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b6c1658a-c428-4b48-a455-02ca2d289adf

📥 Commits

Reviewing files that changed from the base of the PR and between 985de3d and 3c7a67c.

📒 Files selected for processing (3)
  • packages/mcp/README.md
  • packages/mcp/src/index.ts
  • packages/mcp/tests/tools.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/stdio-mcp-key-tools

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds new Model Context Protocol (MCP) tools for managing project API keys, specifically create_api_key, list_api_keys, and revoke_api_key, along with corresponding documentation and unit tests. The feedback points out a potential issue in the revoke_api_key tool where a 204 No Content response from the DELETE request can lead to an undefined return value and an invalid MCP response; returning an explicit success object is recommended to avoid client-side errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/mcp/src/index.ts
Comment on lines +435 to +437
toolHandler(async ({ id }) =>
apiRequest(`/v1/keys/${encodeURIComponent(id)}`, { method: "DELETE" }),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since the backend returns a 204 No Content status for the DELETE request, apiRequest will return undefined. In toolHandler, JSON.stringify(undefined) evaluates to undefined, which results in an invalid MCP TextContent object (missing the required text property) and can cause client-side errors or crashes. Returning an explicit object like { success: true } ensures a valid JSON string is returned to the MCP client.

  toolHandler(async ({ id }) => {
    await apiRequest(`/v1/keys/${encodeURIComponent(id)}`, { method: "DELETE" });
    return { success: true };
  }),

@duyet duyet merged commit a12fe9e into main Jun 18, 2026
6 checks passed
@duyet duyet deleted the claude/stdio-mcp-key-tools branch June 18, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant