get-current-context
Retrieve the active Azure DevOps authentication context for a specific directory, enabling integration with multiple organizations and projects.
Instructions
Get current Azure DevOps context based on directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory path to check (defaults to current working directory) |
Implementation Reference
- src/index.ts:411-463 (handler)The primary handler function that executes the 'get-current-context' tool logic, returning the detected Azure DevOps context 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 in the ListToolsRequestSchema handler, including description and input schema definition.{ 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)Helper method used by the handler to detect project context from directory via DirectoryDetector class.getProjectContext(currentDirectory?: string): { projectName: string; organizationUrl: string } | null { const config = this.detectConfiguration(currentDirectory); if (!config) { return null; } return { projectName: config.project, organizationUrl: config.organizationUrl }; }