Skip to content

Commit cd26a0e

Browse files
author
Lasim
committed
feat(all): add user configuration support in installation process
1 parent 4a78930 commit cd26a0e

File tree

6 files changed

+347
-71
lines changed

6 files changed

+347
-71
lines changed

services/backend/api-spec.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20952,13 +20952,27 @@
2095220952
},
2095320953
"description": "Team-level shared URL query parameters"
2095420954
},
20955+
"user_args": {
20956+
"type": "object",
20957+
"additionalProperties": {
20958+
"type": "string"
20959+
},
20960+
"description": "User-level argument mappings (placeholder -> actual value)"
20961+
},
2095520962
"user_environment_variables": {
2095620963
"type": "object",
2095720964
"additionalProperties": {
2095820965
"type": "string"
2095920966
},
2096020967
"description": "User-level environment variables"
2096120968
},
20969+
"user_headers": {
20970+
"type": "object",
20971+
"additionalProperties": {
20972+
"type": "string"
20973+
},
20974+
"description": "User-level HTTP headers (optional)"
20975+
},
2096220976
"user_url_query_params": {
2096320977
"type": "object",
2096420978
"additionalProperties": {

services/backend/api-spec.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14769,11 +14769,21 @@ paths:
1476914769
additionalProperties:
1477014770
type: string
1477114771
description: Team-level shared URL query parameters
14772+
user_args:
14773+
type: object
14774+
additionalProperties:
14775+
type: string
14776+
description: User-level argument mappings (placeholder -> actual value)
1477214777
user_environment_variables:
1477314778
type: object
1477414779
additionalProperties:
1477514780
type: string
1477614781
description: User-level environment variables
14782+
user_headers:
14783+
type: object
14784+
additionalProperties:
14785+
type: string
14786+
description: User-level HTTP headers (optional)
1477714787
user_url_query_params:
1477814788
type: object
1477914789
additionalProperties:

services/backend/src/routes/mcp/installations/create.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { type FastifyInstance } from 'fastify';
22
import { requireAuthenticationAny, requireOAuthScope } from '../../../middleware/oauthMiddleware';
33
import { requireTeamPermission } from '../../../middleware/roleMiddleware';
44
import { McpInstallationService } from '../../../services/mcpInstallationService';
5+
import { McpUserConfigurationService } from '../../../services/mcpUserConfigurationService';
56
import { SatelliteCommandService } from '../../../services/satelliteCommandService';
67
import { getDb } from '../../../db';
78
import {
@@ -102,6 +103,42 @@ export default async function createInstallationRoute(server: FastifyInstance) {
102103
serverId: installationData.server_id
103104
}, 'MCP server installation created successfully');
104105

106+
// Check if user config data was provided and create user configuration
107+
const hasUserConfig =
108+
(installationData.user_args && Object.keys(installationData.user_args).length > 0) ||
109+
(installationData.user_environment_variables && Object.keys(installationData.user_environment_variables).length > 0) ||
110+
(installationData.user_headers && Object.keys(installationData.user_headers).length > 0) ||
111+
(installationData.user_url_query_params && Object.keys(installationData.user_url_query_params).length > 0);
112+
113+
if (hasUserConfig) {
114+
try {
115+
const userConfigService = new McpUserConfigurationService(db, request.log);
116+
await userConfigService.createUserConfiguration(
117+
installation.id,
118+
userId,
119+
teamId,
120+
{
121+
user_args: installationData.user_args,
122+
user_env: installationData.user_environment_variables,
123+
user_headers: installationData.user_headers,
124+
user_url_query_params: installationData.user_url_query_params
125+
}
126+
);
127+
request.log.info({
128+
operation: 'create_mcp_installation',
129+
installationId: installation.id,
130+
userId
131+
}, 'User configuration created during installation');
132+
} catch (userConfigError) {
133+
// Log but don't fail - team installation succeeded
134+
request.log.warn({
135+
operation: 'create_mcp_installation',
136+
installationId: installation.id,
137+
error: userConfigError instanceof Error ? userConfigError.message : 'Unknown error'
138+
}, 'Failed to create user configuration during installation');
139+
}
140+
}
141+
105142
// Create satellite commands for immediate notification (3-second response goal)
106143
try {
107144
const satelliteCommandService = new SatelliteCommandService(db, request.log);

services/backend/src/routes/mcp/installations/schemas.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,21 @@ export const CREATE_INSTALLATION_REQUEST_SCHEMA = {
119119
additionalProperties: { type: 'string' },
120120
description: 'Team-level shared URL query parameters'
121121
},
122+
user_args: {
123+
type: 'object',
124+
additionalProperties: { type: 'string' },
125+
description: 'User-level argument mappings (placeholder -> actual value)'
126+
},
122127
user_environment_variables: {
123128
type: 'object',
124129
additionalProperties: { type: 'string' },
125130
description: 'User-level environment variables'
126131
},
132+
user_headers: {
133+
type: 'object',
134+
additionalProperties: { type: 'string' },
135+
description: 'User-level HTTP headers (optional)'
136+
},
127137
user_url_query_params: {
128138
type: 'object',
129139
additionalProperties: { type: 'string' },
@@ -610,7 +620,9 @@ export interface CreateInstallationRequest {
610620
team_env?: Record<string, string>;
611621
team_headers?: Record<string, string>;
612622
team_url_query_params?: Record<string, string>;
623+
user_args?: Record<string, string>;
613624
user_environment_variables?: Record<string, string>;
625+
user_headers?: Record<string, string>;
614626
user_url_query_params?: Record<string, string>;
615627
}
616628

0 commit comments

Comments
 (0)