Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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 }; } }
  • 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: {} } };
  • 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 ];
  • 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 ];
  • 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() }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/martin-1103/mcp2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server