Skip to content

Commit 3729357

Browse files
author
Lasim
committed
feat(backend): add OAuth token management services and utilities
1 parent 424a4bc commit 3729357

21 files changed

+6971
-5
lines changed

services/backend/api-spec.json

Lines changed: 327 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12033,6 +12033,11 @@
1203312033
"type": "string",
1203412034
"description": "Team identifier"
1203512035
},
12036+
"context_window_size": {
12037+
"type": "number",
12038+
"description": "Context window size used for calculations (in tokens). Claude: 200,000, GPT-4: 128,000",
12039+
"default": 200000
12040+
},
1203612041
"total_installations": {
1203712042
"type": "number",
1203812043
"description": "Total number of installations with discovered tools"
@@ -12140,6 +12145,27 @@
1214012145
"average_tokens_per_tool": {
1214112146
"type": "number",
1214212147
"description": "Average tokens per tool"
12148+
},
12149+
"tools": {
12150+
"type": "array",
12151+
"items": {
12152+
"type": "object",
12153+
"properties": {
12154+
"tool_name": {
12155+
"type": "string",
12156+
"description": "Name of the tool"
12157+
},
12158+
"token_count": {
12159+
"type": "number",
12160+
"description": "Token count for this tool"
12161+
}
12162+
},
12163+
"required": [
12164+
"tool_name",
12165+
"token_count"
12166+
]
12167+
},
12168+
"description": "List of tools with their token counts"
1214312169
}
1214412170
},
1214512171
"required": [
@@ -12149,14 +12175,16 @@
1214912175
"server_name",
1215012176
"tool_count",
1215112177
"total_tokens",
12152-
"average_tokens_per_tool"
12178+
"average_tokens_per_tool",
12179+
"tools"
1215312180
]
1215412181
},
1215512182
"description": "Breakdown by installation"
1215612183
}
1215712184
},
1215812185
"required": [
1215912186
"team_id",
12187+
"context_window_size",
1216012188
"total_installations",
1216112189
"total_tools",
1216212190
"total_tokens",
@@ -23718,6 +23746,304 @@
2371823746
}
2371923747
}
2372023748
},
23749+
"/api/teams/{teamId}/mcp/installations/authorize": {
23750+
"post": {
23751+
"summary": "Initiate OAuth flow for MCP server installation",
23752+
"tags": [
23753+
"MCP Installations",
23754+
"OAuth"
23755+
],
23756+
"description": "Creates a pending MCP server installation and returns OAuth authorization URL for user authentication. Requires Content-Type: application/json header when sending request body. Supports both cookie-based authentication (for web users) and OAuth2 Bearer token authentication (for CLI users). Requires mcp:read scope for OAuth2 access.",
23757+
"requestBody": {
23758+
"content": {
23759+
"application/json": {
23760+
"schema": {
23761+
"type": "object",
23762+
"properties": {
23763+
"server_id": {
23764+
"type": "string",
23765+
"minLength": 1,
23766+
"description": "MCP server ID that requires OAuth"
23767+
},
23768+
"installation_name": {
23769+
"type": "string",
23770+
"minLength": 1,
23771+
"maxLength": 100,
23772+
"description": "Custom name for this installation (optional)"
23773+
},
23774+
"team_config": {
23775+
"type": "object",
23776+
"additionalProperties": true,
23777+
"description": "Team-level configuration for installation (optional)"
23778+
}
23779+
},
23780+
"required": [
23781+
"server_id"
23782+
],
23783+
"additionalProperties": false
23784+
}
23785+
}
23786+
},
23787+
"required": true
23788+
},
23789+
"parameters": [
23790+
{
23791+
"schema": {
23792+
"type": "string",
23793+
"minLength": 1
23794+
},
23795+
"in": "path",
23796+
"name": "teamId",
23797+
"required": true,
23798+
"description": "Team ID is required"
23799+
}
23800+
],
23801+
"security": [
23802+
{
23803+
"cookieAuth": []
23804+
},
23805+
{
23806+
"bearerAuth": []
23807+
}
23808+
],
23809+
"responses": {
23810+
"200": {
23811+
"description": "OAuth authorization URL generated successfully",
23812+
"content": {
23813+
"application/json": {
23814+
"schema": {
23815+
"type": "object",
23816+
"properties": {
23817+
"installation_id": {
23818+
"type": "string",
23819+
"description": "Unique installation ID for the pending OAuth installation"
23820+
},
23821+
"authorization_url": {
23822+
"type": "string",
23823+
"format": "uri",
23824+
"description": "OAuth authorization URL to redirect user to for authentication"
23825+
},
23826+
"expires_at": {
23827+
"type": "string",
23828+
"format": "date-time",
23829+
"description": "ISO 8601 timestamp when the OAuth state expires"
23830+
}
23831+
},
23832+
"required": [
23833+
"installation_id",
23834+
"authorization_url",
23835+
"expires_at"
23836+
],
23837+
"description": "OAuth authorization URL generated successfully"
23838+
}
23839+
}
23840+
}
23841+
},
23842+
"400": {
23843+
"description": "Bad Request - Invalid input or validation error",
23844+
"content": {
23845+
"application/json": {
23846+
"schema": {
23847+
"type": "object",
23848+
"properties": {
23849+
"success": {
23850+
"type": "boolean",
23851+
"default": false,
23852+
"description": "Indicates the operation failed"
23853+
},
23854+
"error": {
23855+
"type": "string",
23856+
"description": "Error message describing what went wrong"
23857+
}
23858+
},
23859+
"required": [
23860+
"success",
23861+
"error"
23862+
],
23863+
"description": "Bad Request - Invalid input or validation error"
23864+
}
23865+
}
23866+
}
23867+
},
23868+
"401": {
23869+
"description": "Unauthorized - Authentication required or invalid token",
23870+
"content": {
23871+
"application/json": {
23872+
"schema": {
23873+
"type": "object",
23874+
"properties": {
23875+
"success": {
23876+
"type": "boolean",
23877+
"default": false,
23878+
"description": "Indicates the operation failed"
23879+
},
23880+
"error": {
23881+
"type": "string",
23882+
"description": "Error message describing what went wrong"
23883+
}
23884+
},
23885+
"required": [
23886+
"success",
23887+
"error"
23888+
],
23889+
"description": "Unauthorized - Authentication required or invalid token"
23890+
}
23891+
}
23892+
}
23893+
},
23894+
"403": {
23895+
"description": "Forbidden - Insufficient permissions or scope",
23896+
"content": {
23897+
"application/json": {
23898+
"schema": {
23899+
"type": "object",
23900+
"properties": {
23901+
"success": {
23902+
"type": "boolean",
23903+
"default": false,
23904+
"description": "Indicates the operation failed"
23905+
},
23906+
"error": {
23907+
"type": "string",
23908+
"description": "Error message describing what went wrong"
23909+
}
23910+
},
23911+
"required": [
23912+
"success",
23913+
"error"
23914+
],
23915+
"description": "Forbidden - Insufficient permissions or scope"
23916+
}
23917+
}
23918+
}
23919+
},
23920+
"404": {
23921+
"description": "MCP server not found",
23922+
"content": {
23923+
"application/json": {
23924+
"schema": {
23925+
"type": "object",
23926+
"properties": {
23927+
"success": {
23928+
"type": "boolean",
23929+
"default": false,
23930+
"description": "Indicates the operation failed"
23931+
},
23932+
"error": {
23933+
"type": "string",
23934+
"description": "Error message describing what went wrong"
23935+
}
23936+
},
23937+
"required": [
23938+
"success",
23939+
"error"
23940+
],
23941+
"description": "MCP server not found"
23942+
}
23943+
}
23944+
}
23945+
},
23946+
"500": {
23947+
"description": "Internal Server Error",
23948+
"content": {
23949+
"application/json": {
23950+
"schema": {
23951+
"type": "object",
23952+
"properties": {
23953+
"success": {
23954+
"type": "boolean",
23955+
"default": false,
23956+
"description": "Indicates the operation failed"
23957+
},
23958+
"error": {
23959+
"type": "string",
23960+
"description": "Error message describing what went wrong"
23961+
}
23962+
},
23963+
"required": [
23964+
"success",
23965+
"error"
23966+
],
23967+
"description": "Internal Server Error"
23968+
}
23969+
}
23970+
}
23971+
}
23972+
}
23973+
}
23974+
},
23975+
"/api/api/teams/{teamId}/mcp/installations/{installationId}/oauth/callback": {
23976+
"get": {
23977+
"tags": [
23978+
"MCP Installations",
23979+
"OAuth"
23980+
],
23981+
"description": "OAuth callback endpoint for MCP server authentication",
23982+
"parameters": [
23983+
{
23984+
"schema": {
23985+
"type": "string"
23986+
},
23987+
"in": "query",
23988+
"name": "code",
23989+
"required": false,
23990+
"description": "Authorization code from OAuth provider"
23991+
},
23992+
{
23993+
"schema": {
23994+
"type": "string"
23995+
},
23996+
"in": "query",
23997+
"name": "state",
23998+
"required": false,
23999+
"description": "State parameter for CSRF protection"
24000+
},
24001+
{
24002+
"schema": {
24003+
"type": "string"
24004+
},
24005+
"in": "query",
24006+
"name": "error",
24007+
"required": false,
24008+
"description": "OAuth error code if authorization failed"
24009+
},
24010+
{
24011+
"schema": {
24012+
"type": "string"
24013+
},
24014+
"in": "query",
24015+
"name": "error_description",
24016+
"required": false,
24017+
"description": "Human-readable error description"
24018+
},
24019+
{
24020+
"schema": {
24021+
"type": "string",
24022+
"minLength": 1
24023+
},
24024+
"in": "path",
24025+
"name": "teamId",
24026+
"required": true,
24027+
"description": "Team ID that owns the installation"
24028+
},
24029+
{
24030+
"schema": {
24031+
"type": "string",
24032+
"minLength": 1
24033+
},
24034+
"in": "path",
24035+
"name": "installationId",
24036+
"required": true,
24037+
"description": "Installation ID"
24038+
}
24039+
],
24040+
"responses": {
24041+
"200": {
24042+
"description": "Default Response"
24043+
}
24044+
}
24045+
}
24046+
},
2372124047
"/api/teams/{teamId}/mcp/installations/{installationId}/user-configs": {
2372224048
"post": {
2372324049
"summary": "Create user configuration for MCP installation",

0 commit comments

Comments
 (0)