Skip to content

feat: pass auth info to local MCP server - #122

Merged
sweetmantech merged 7 commits into
testfrom
sweetmantech/myc-3939-api-apichat-pass-auth-info-to-local-mcp-server
Jan 16, 2026
Merged

sweetmantech merged 7 commits into
testfrom
sweetmantech/myc-3939-api-apichat-pass-auth-info-to-local-mcp-server

Conversation

@sweetmantech

Copy link
Copy Markdown
Contributor

Summary

  • Add AuthenticatedInMemoryTransport wrapper to inject auth info into MCP messages
  • Extract orgId from API key details in validateChatRequest
  • Pass accountId and orgId to MCP tools via authenticated transport
  • Fixes MCP tool authentication errors ("No authorization provided")

Test plan

  • Unit tests for validateChatRequest returning orgId
  • Unit tests for setupToolsForRequest with orgId
  • Verify create_new_artist tool works with proper auth context
  • Test chat endpoint with org API key

🤖 Generated with Claude Code

sweetmantech and others added 2 commits January 15, 2026 19:36
Add AuthenticatedInMemoryTransport wrapper to inject accountId into MCP
tool calls. This allows tools like create_new_artist to resolve the
authenticated user without requiring HTTP auth headers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
RED-GREEN-REFACTOR:
- Add tests for orgId extraction in validateChatRequest
- Add tests for orgId passing in setupToolsForRequest
- Update ChatRequestBody type to include orgId
- Extract orgId from API key details in validateChatRequest
- Pass orgId through AuthenticatedInMemoryTransport to MCP tools

This enables MCP tools like create_new_artist to properly resolve
organization context when called via org API keys.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Review Updated (UTC)
recoup-api Ready Ready Preview Jan 16, 2026 1:33am

@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown

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.

Update test files and email handler to include required orgId field.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pass orgId through getGeneralAgent to getSystemPrompt so the AI model
can see the organization context in the system prompt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test if system prompt orgId is sufficient without MCP auth injection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Mock @/lib/keys/getApiKeyDetails and MCP SDK modules to prevent
Supabase import chain errors in test files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sweetmantech
sweetmantech merged commit 15f29a1 into test Jan 16, 2026
@sweetmantech
sweetmantech deleted the sweetmantech/myc-3939-api-apichat-pass-auth-info-to-local-mcp-server branch January 16, 2026 01:39

This branch was successfully deployed

1 active deployment
Preview — 84649f80 Deployed Jan 16, 2026 by vercel[bot]
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