feat: add per-user support via apiKey and userId#2
Open
samarsheikh001 wants to merge 1 commit intoComposioHQ:masterfrom
Open
feat: add per-user support via apiKey and userId#2samarsheikh001 wants to merge 1 commit intoComposioHQ:masterfrom
samarsheikh001 wants to merge 1 commit intoComposioHQ:masterfrom
Conversation
Adds two new config fields for multi-tenant use cases: - apiKey (ak_...): Alternative to consumerKey for backend API / tool router endpoints. Uses x-api-key header instead of x-consumer-api-key. - userId: Per-user identifier appended as ?user_id= to the MCP URL when using apiKey mode. Scopes connected accounts per user. This enables B2C platforms to deploy one agent per user with isolated Composio connected accounts, instead of sharing a single identity via consumerKey. Backwards compatible — existing consumerKey + connect.composio.dev setups continue to work unchanged.
848a9e4 to
a84990d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new config fields for multi-tenant / B2C use cases where each user needs isolated Composio connected accounts:
apiKey(ak_...): Alternative toconsumerKeyfor backend API / tool router endpoints. Usesx-api-keyheader instead ofx-consumer-api-key.userId: Per-user identifier appended as?user_id=to the MCP URL when usingapiKeymode. Scopes connected accounts per user.Problem
The current plugin only supports
consumerKey(ck_...) with thex-consumer-api-keyheader againstconnect.composio.dev/mcp. This means all agents using the same consumer key share a single identity — connected accounts from one user are visible to others. For multi-tenant B2C platforms deploying one agent per user, this is a blocker.Solution
When
apiKeyis provided (instead of or alongsideconsumerKey), the plugin:x-api-keyheader instead ofx-consumer-api-keyuserIdis set, appends?user_id={userId}to the MCP URLbackend.composio.dev/tool_router/trs_XXX/mcporbackend.composio.dev/v3/mcp/SERVER_ID) which support per-user scopingBackwards Compatible
Existing
consumerKey+connect.composio.devsetups continue to work unchanged. The new fields are optional and default to empty strings.Config examples
Existing (unchanged):
{ "consumerKey": "ck_your_key", "mcpUrl": "https://connect.composio.dev/mcp" }New — per-user via tool router session:
{ "apiKey": "ak_your_key", "mcpUrl": "https://backend.composio.dev/tool_router/trs_XXX/mcp" }New — per-user via server ID + userId:
{ "apiKey": "ak_your_key", "mcpUrl": "https://backend.composio.dev/v3/mcp/SERVER_ID", "userId": "user_123" }Files changed
src/types.ts— AddedapiKeyanduserIdtoComposioConfigsrc/config.ts— Parse new fields from config/env vars (COMPOSIO_API_KEY,COMPOSIO_USER_ID,COMPOSIO_MCP_URL)index.ts— Switch auth header based on credential type, appenduser_idto URL when applicableopenclaw.plugin.json— AddedapiKeyanduserIdto config schema + UI hintsTest plan
consumerKey+ defaultmcpUrlstill worksapiKeywith tool router URL connects successfullyapiKey+userIdappends?user_id=to URLapiKey+userIdwith URL already containing?uses&user_id=COMPOSIO_API_KEY,COMPOSIO_USER_ID,COMPOSIO_MCP_URLare picked up