terros_get_current_user
Retrieve the authenticated user's profile from Terros to access account details and manage user information.
Instructions
Get the authenticated user's own profile from Terros.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/users.ts:18-29 (handler)The tool registration and handler for 'terros_get_current_user'. This is where the tool is registered with the MCP server and the async handler that executes when called, which returns the current user's profile via client.getCurrentUser().
server.tool( "terros_get_current_user", "Get the authenticated user's own profile from Terros.", {}, async () => { try { return { content: [{ type: "text", text: toJsonText(await client.getCurrentUser()) }] }; } catch (error) { return { content: [{ type: "text", text: toErrorText(error) }], isError: true }; } } ); - src/client.ts:18-20 (helper)The getCurrentUser method in TerrosApiClient that makes the actual API call. It sends a POST request to '/user/get' with an empty body to retrieve the authenticated user's profile.
async getCurrentUser(): Promise<unknown> { return this.post("/user/get", {}); } - src/client.ts:61-88 (helper)The HTTP POST method that handles all API requests including the getCurrentUser call. It sets up the authorization header, makes the fetch request, and handles errors.
private async post(path: string, body: unknown): Promise<unknown> { const url = `${this.baseUrl}${path}`; const response = await fetch(url, { method: "POST", headers: { Authorization: `ApiKey ${this.apiKey}`, "Content-Type": "application/json", Accept: "application/json", }, body: JSON.stringify(body), }); const contentType = response.headers.get("content-type") ?? ""; const isJson = contentType.includes("application/json"); const payload = isJson ? await response.json() : await response.text(); if (!response.ok) { const p = payload as Record<string, unknown> | undefined; const detail = (typeof p?.message === "string" ? p.message : undefined) ?? (typeof payload === "string" ? payload : undefined) ?? response.statusText; throw new Error(`Terros API ${response.status}: ${detail}`); } return payload; } - src/types.ts:18-25 (schema)The TerrosUser interface that defines the structure of user data returned by the getCurrentUser API call, including id, email, firstName, lastName, and role fields.
export interface TerrosUser { id: string; email?: string; firstName?: string; lastName?: string; role?: string; [key: string]: unknown; } - src/server.ts:24-24 (registration)Where registerUserTools is called to register all user-related tools including terros_get_current_user when creating the MCP server.
registerUserTools(server, client);