get-current-context
Retrieve the current Azure DevOps context from a specified directory path, enabling integration with multiple organizations and projects using the DevOps Enhanced MCP server.
Instructions
Get current Azure DevOps context based on directory
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory path to check (defaults to current working directory) |
Input Schema (JSON Schema)
{
"properties": {
"directory": {
"description": "Directory path to check (defaults to current working directory)",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:411-463 (handler)The main handler function that implements the logic for the 'get-current-context' tool. It determines the current Azure DevOps context using either local configuration or directory detection and returns it as JSON.private handleGetCurrentContext(args?: any): any { const directory = args?.directory || process.cwd(); // If using local configuration, return current config if (!this.directoryDetector && this.currentConfig) { return { content: [{ type: 'text', text: JSON.stringify({ organizationUrl: this.currentConfig.organizationUrl, project: this.currentConfig.project, directory: directory, configurationSource: 'local', configFile: '.azure-devops.json' }, null, 2), }], }; } // Fall back to directory detector if available if (this.directoryDetector) { const context = this.directoryDetector.getProjectContext(directory); if (!context) { return { content: [{ type: 'text', text: 'No Azure DevOps context configured for the specified directory.', }], }; } return { content: [{ type: 'text', text: JSON.stringify({ organizationUrl: context.organizationUrl, project: context.projectName, directory: directory, configurationSource: 'environment', configuredDirectories: this.directoryDetector.getConfiguredDirectories(), }, null, 2), }], }; } return { content: [{ type: 'text', text: 'No Azure DevOps configuration found.', }], }; }
- src/index.ts:332-344 (registration)Registration of the 'get-current-context' tool including its name, description, and input schema in the ListTools response.{ name: 'get-current-context', description: 'Get current Azure DevOps context based on directory', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Directory path to check (defaults to current working directory)', }, }, }, },
- src/index.ts:335-342 (schema)Input schema definition for the 'get-current-context' tool.inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Directory path to check (defaults to current working directory)', }, },
- src/directory-detector.ts:74-84 (helper)Supporting helper method called by the tool handler to retrieve the project context (organization URL and project name) for a given directory.getProjectContext(currentDirectory?: string): { projectName: string; organizationUrl: string } | null { const config = this.detectConfiguration(currentDirectory); if (!config) { return null; } return { projectName: config.project, organizationUrl: config.organizationUrl }; }