get_project_context
Retrieve project environments and folder structures to understand API development context and available resources for testing workflows.
Instructions
Get project context including environments and folders. Validates MCP token and returns enriched project data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/auth.ts:50-147 (handler)The core handler function for the 'get_project_context' tool. It initializes authentication dependencies, detects the project configuration, fetches the project context from the BackendClient, processes the response (handling different formats), and returns a formatted text response with project details, environments, and folders.[getProjectContextTool.name]: async (args: Record<string, any>) => { try { const { configManager, backendClient } = await getAuthDependencies(); // Get project ID from config const config = await configManager.detectProjectConfig(); console.error('[AUTH] Config loaded:', JSON.stringify(config, null, 2)); if (!config) { throw new Error('No configuration found - make sure gassapi.json exists'); } const projectId = config?.project?.id; if (!projectId) { throw new Error('Project ID not found in gassapi.json configuration'); } const result = await backendClient.getProjectContext(projectId); if (result.success && result.data) { // Handle different response formats from backend let project: any, environments: any[], folders: any[], user: any; if (result.data.project) { // Full context response (what we want from project_context endpoint) project = result.data.project; environments = result.data.environments || []; folders = result.data.folders || []; user = result.data.user; } else { // Basic project response (what we get from project endpoint) project = result.data; environments = []; folders = []; user = { id: project.owner_id, token_type: 'mcp', authenticated: true }; } let contextText = `š Project Context Retrieved\n\n`; contextText += `š Authentication: ${user?.token_type === 'mcp' ? 'ā MCP Token Validated' : 'ā JWT Authenticated'}\n\n`; contextText += `š Project Details:\n`; contextText += `- Name: ${project.name}\n`; contextText += `- ID: ${project.id}\n`; if (project.description) { contextText += `- Description: ${project.description}\n`; } if (environments && environments.length > 0) { contextText += `\nš Environments (${environments.length}):\n`; environments.forEach((env: any) => { contextText += `- ${env.name} (${env.id})${env.is_default ? ' [Default]' : ''}\n`; }); } if (folders && folders.length > 0) { contextText += `\nš Folders (${folders.length}):\n`; folders.forEach((folder: any) => { contextText += `- ${folder.name} (${folder.id})`; if (folder.endpoint_count) { contextText += ` - ${folder.endpoint_count} endpoints`; } contextText += '\n'; }); } return { content: [ { type: 'text', text: contextText } ] }; } else { return { content: [ { type: 'text', text: `ā Failed to get project context: ${result.error || 'Unknown error'}` } ], isError: true }; } } catch (error) { return { content: [ { type: 'text', text: `ā Project context error: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/auth.ts:36-43 (schema)Tool definition including name, description, and input schema (empty object, no parameters required).export const getProjectContextTool: McpTool = { name: 'get_project_context', description: 'Get project context including environments and folders. Validates MCP token and returns enriched project data.', inputSchema: { type: 'object', properties: {} } };
- src/tools/auth.ts:152-154 (registration)Exports the get_project_context tool as part of AUTH_TOOLS array for inclusion in the main tool registry.export const AUTH_TOOLS: McpTool[] = [ getProjectContextTool ];
- src/tools/index.ts:30-38 (registration)Registers the get_project_context tool (via ...AUTH_TOOLS) in the complete ALL_TOOLS list used by the MCP server.export const ALL_TOOLS: McpTool[] = [ ...CORE_TOOLS, ...AUTH_TOOLS, ...environmentTools, ...folderTools, ...ENDPOINT_TOOLS, ...testingTools, ...flowTools ];
- src/tools/index.ts:192-202 (registration)Registers the handler for get_project_context (via ...createAuthToolHandlers()) in the complete tool handlers map.export function createAllToolHandlers(): Record<string, (args: any) => Promise<McpToolResponse>> { return { ...createCoreToolHandlers(), ...createAuthToolHandlers(), ...createEnvironmentToolHandlers(), ...createFolderToolHandlers(), ...createEndpointToolHandlers(), ...createTestingToolHandlers(), ...createFlowToolHandlers() }; }