Skip to content

feat: accept api_key for authentication in create_new_artist MCP tool#118

Merged
sweetmantech merged 8 commits intotestfrom
sweetmantech/myc-3931-api-recoup
Jan 15, 2026
Merged

feat: accept api_key for authentication in create_new_artist MCP tool#118
sweetmantech merged 8 commits intotestfrom
sweetmantech/myc-3931-api-recoup

Conversation

@sweetmantech
Copy link
Contributor

Summary

  • Add optional api_key parameter to create_new_artist MCP tool
  • When api_key is provided, automatically resolve account_id via getApiKeyDetails
  • Support account_id override for organization API keys (with access validation)
  • Backwards compatible - still accepts account_id directly from system prompt

Authentication Flow

  1. If api_key provided → validate and resolve accountId
  2. If account_id also provided → validate org has access to target account
  3. If neither provided → return error

Test plan

  • All 11 tests pass
  • Tests cover: api_key resolution, invalid key, org override, access denied

🤖 Generated with Claude Code

- Add optional api_key parameter to resolve account_id automatically
- Use getApiKeyDetails to validate API key and get accountId
- Support account_id override for org API keys with access validation
- Return clear error messages for invalid keys or access denied
- Add comprehensive tests for new authentication flow

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link
Contributor

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
recoup-api Ready Ready Preview Jan 15, 2026 8:55pm

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

- Implement withMcpAuth wrapper for MCP server-level authentication
- Remove api_key parameter from create_new_artist tool schema
- Tool now receives accountId via extra.authInfo from the auth layer
- MCP server accepts API key via Authorization: Bearer or x-api-key header
- Update tests to use new auth flow with mock authInfo

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Unauthenticated requests will now receive a 401 response.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Follow SRP - move auth verification to its own module.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove x-api-key header support, use only Authorization: Bearer.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Export McpAuthInfo and McpAuthInfoExtra types from verifyApiKey.ts
for use in tool handlers.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Move account resolution logic with org access validation to its own module.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sweetmantech sweetmantech merged commit ab92fd0 into test Jan 15, 2026
4 checks passed
@sweetmantech sweetmantech deleted the sweetmantech/myc-3931-api-recoup branch January 15, 2026 20:56
sweetmantech added a commit that referenced this pull request Jan 15, 2026
…#118) (#119)

* feat: accept api_key for authentication in create_new_artist MCP tool

- Add optional api_key parameter to resolve account_id automatically
- Use getApiKeyDetails to validate API key and get accountId
- Support account_id override for org API keys with access validation
- Return clear error messages for invalid keys or access denied
- Add comprehensive tests for new authentication flow



* refactor: move API key authentication to MCP server level

- Implement withMcpAuth wrapper for MCP server-level authentication
- Remove api_key parameter from create_new_artist tool schema
- Tool now receives accountId via extra.authInfo from the auth layer
- MCP server accepts API key via Authorization: Bearer or x-api-key header
- Update tests to use new auth flow with mock authInfo



* feat: require API key authentication for MCP server

Unauthenticated requests will now receive a 401 response.



* refactor: extract verifyApiKey to lib/mcp/verifyApiKey.ts

Follow SRP - move auth verification to its own module.



* refactor: use Authorization: Bearer header for MCP API key auth

Remove x-api-key header support, use only Authorization: Bearer.



* refactor: add McpAuthInfo type for typed auth info access

Export McpAuthInfo and McpAuthInfoExtra types from verifyApiKey.ts
for use in tool handlers.



* refactor: extract resolveAccountId to lib/mcp/resolveAccountId.ts

Move account resolution logic with org access validation to its own module.



* fix: add index signature to McpAuthInfoExtra for AuthInfo compatibility



---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
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