Get current user information
get_current_userRetrieve details of the currently authenticated user to verify identity and permissions in Octopus Deploy.
Instructions
Get information about the current authenticated user
This tool retrieves information about the currently authenticated user from the Octopus Deploy API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/getCurrentUser.ts:30-60 (handler)The handler function that executes the 'get_current_user' tool logic. It creates an Octopus API client, calls GET ~/api/users/me, and returns the current user's details (id, username, displayName, isActive, isService, emailAddress, canPasswordBeEdited, isRequestor) as JSON text content.
async () => { try { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const user = await client.get<CurrentUser>("~/api/users/me"); const currentUser = { id: user.Id, username: user.Username, displayName: user.DisplayName, isActive: user.IsActive, isService: user.IsService, emailAddress: user.EmailAddress, canPasswordBeEdited: user.CanPasswordBeEdited, isRequestor: user.IsRequestor, }; return { content: [ { type: "text", text: JSON.stringify(currentUser), }, ], }; } catch (error) { handleOctopusApiError(error, {}); } } ); - src/tools/getCurrentUser.ts:8-17 (schema)The CurrentUser interface defines the shape of the user data returned by the tool (Id, Username, DisplayName, IsActive, IsService, EmailAddress, CanPasswordBeEdited, IsRequestor).
interface CurrentUser { Id: string; Username: string; DisplayName: string; IsActive: boolean; IsService: boolean; EmailAddress: string; CanPasswordBeEdited: boolean; IsRequestor: boolean; } - src/tools/getCurrentUser.ts:63-67 (registration)Registers the tool definition in the global TOOL_REGISTRY with toolName 'get_current_user', toolset 'context', and readOnly: true. The registerFn is registerGetCurrentUserTool which calls server.registerTool() with the name 'get_current_user'.
registerToolDefinition({ toolName: "get_current_user", config: { toolset: "context", readOnly: true }, registerFn: registerGetCurrentUserTool, }); - src/tools/getCurrentUser.ts:19-22 (registration)The registerGetCurrentUserTool function that calls server.registerTool('get_current_user') with inputSchema: {}, annotations from READ_ONLY_TOOL_ANNOTATIONS, and the async handler.
export function registerGetCurrentUserTool(server: McpServer) { server.registerTool( "get_current_user", { - src/helpers/userCache.ts:18-27 (helper)Cached version of getCurrentUser used by other tools (like findInterruptions). Implements a 1-hour TTL cache around the ~/api/users/me API call to avoid redundant requests.
export async function getCurrentUserCached(client: Client): Promise<CurrentUser> { const now = Date.now(); if (cached && now - cached.timestamp < CACHE_TTL) { return cached.user; } const user = await client.get<CurrentUser>("~/api/users/me"); cached = { user, timestamp: now }; return user; }