get_me
Retrieve authenticated user details including ID, display name, and email from Azure DevOps for identity verification and access management.
Instructions
Get details of the authenticated user (id, displayName, email)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Core handler function that implements the get_me tool logic by fetching the authenticated user's profile from the Azure DevOps Profile API using axios and appropriate authentication.export async function getMe(connection: WebApi): Promise<UserProfile> { try { // Extract organization from the connection URL const { organization } = extractOrgFromUrl(connection.serverUrl); // Get the authorization header const authHeader = await getAuthorizationHeader(); // Make direct call to the Profile API endpoint // Note: This API is in the vssps.dev.azure.com domain, not dev.azure.com const response = await axios.get( `https://vssps.dev.azure.com/${organization}/_apis/profile/profiles/me?api-version=7.1`, { headers: { Authorization: authHeader, 'Content-Type': 'application/json', }, }, ); const profile = response.data; // Return the user profile with required fields return { id: profile.id, displayName: profile.displayName || '', email: profile.emailAddress || '', }; } catch (error) { // Handle authentication errors if ( axios.isAxiosError(error) && (error.response?.status === 401 || error.response?.status === 403) ) { throw new AzureDevOpsAuthenticationError( `Authentication failed: ${error.message}`, ); } // If it's already an AzureDevOpsError, rethrow it if (error instanceof AzureDevOpsError) { throw error; } // Otherwise, wrap it in a generic error throw new AzureDevOpsError( `Failed to get user information: ${error instanceof Error ? error.message : String(error)}`, ); }
- src/features/users/tool-definitions.ts:8-15 (registration)Registration of the get_me tool in the usersTools array, including name, description, and input schema derived from Zod schema.export const usersTools: ToolDefinition[] = [ { name: 'get_me', description: 'Get details of the authenticated user (id, displayName, email)', inputSchema: zodToJsonSchema(GetMeSchema), }, ];
- src/features/users/schemas.ts:6-6 (schema)Zod input schema for the get_me tool, which requires no parameters (empty object).export const GetMeSchema = z.object({}).strict();
- src/features/users/index.ts:35-49 (handler)MCP request handler for users tools, dispatching to getMe for 'get_me' tool name and formatting response as MCP content.export const handleUsersRequest: RequestHandler = async ( connection: WebApi, request: CallToolRequest, ): Promise<{ content: Array<{ type: string; text: string }> }> => { switch (request.params.name) { case 'get_me': { const result = await getMe(connection); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } default: throw new Error(`Unknown users tool: ${request.params.name}`); } };
- src/features/users/index.ts:25-30 (registration)Request identifier function that checks if the tool name is 'get_me' to route to users feature.export const isUsersRequest: RequestIdentifier = ( request: CallToolRequest, ): boolean => { const toolName = request.params.name; return ['get_me'].includes(toolName); };