konsulto_whoami
Retrieve current user identity, tenant, role permissions, MCP token expiry, and active audit pin to orient the session before performing any actions.
Instructions
Show who the MCP is acting as, their permissions, the active audit, and how authentication is configured. Call this first in any session to orient yourself before performing actions. Returns user identity, tenant, role permissions, MCP token expiry, and active audit pin.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:70-101 (handler)The handler function for the konsulto_whoami tool. Calls GET /users/profile to fetch identity, permissions, and tenant info, gets the active audit from session state, and includes workspace config pin. No input schema needed (empty object {}). Uses ok() helper to return JSON result.
server.tool( 'konsulto_whoami', 'Show who the MCP is acting as, their permissions, the active audit, and ' + 'how authentication is configured. Call this first in any session to ' + 'orient yourself before performing actions. Returns user identity, ' + 'tenant, role permissions, MCP token expiry, and active audit pin.', {}, async () => { try { const profile = (await client.get<any>('/users/profile')) as any; const active = state.getActiveAudit(); return ok({ user: { id: profile?._id ?? profile?.userId, username: profile?.username, email: profile?.email, name: [profile?.firstName, profile?.lastName].filter(Boolean).join(' ') || profile?.username, }, tenant: { features: profile?.tenantFeatures ?? {}, }, permissions: profile?.resolvedPermissions ?? [], activeAudit: active, workspaceConfig: workspace ? { configPath: workspace.configPath, pinnedAudit: workspace.audit } : null, }); } catch (err) { return errResult(err); } }, ); - src/server.ts:70-101 (registration)Registration of konsulto_whoami via server.tool() on the McpServer instance. The tool is registered in the buildServer() function along with all other tools.
server.tool( 'konsulto_whoami', 'Show who the MCP is acting as, their permissions, the active audit, and ' + 'how authentication is configured. Call this first in any session to ' + 'orient yourself before performing actions. Returns user identity, ' + 'tenant, role permissions, MCP token expiry, and active audit pin.', {}, async () => { try { const profile = (await client.get<any>('/users/profile')) as any; const active = state.getActiveAudit(); return ok({ user: { id: profile?._id ?? profile?.userId, username: profile?.username, email: profile?.email, name: [profile?.firstName, profile?.lastName].filter(Boolean).join(' ') || profile?.username, }, tenant: { features: profile?.tenantFeatures ?? {}, }, permissions: profile?.resolvedPermissions ?? [], activeAudit: active, workspaceConfig: workspace ? { configPath: workspace.configPath, pinnedAudit: workspace.audit } : null, }); } catch (err) { return errResult(err); } }, ); - src/server.ts:70-76 (schema)The konsulto_whoami tool has an empty schema object {} — it accepts no inputs. It is a pure query tool that returns current session context.
server.tool( 'konsulto_whoami', 'Show who the MCP is acting as, their permissions, the active audit, and ' + 'how authentication is configured. Call this first in any session to ' + 'orient yourself before performing actions. Returns user identity, ' + 'tenant, role permissions, MCP token expiry, and active audit pin.', {}, - src/server.ts:1008-1012 (helper)The ok() helper is used by konsulto_whoami to wrap the JSON response into the MCP content array format.
function ok(payload: unknown) { return { content: [{ type: 'text' as const, text: JSON.stringify(payload, null, 2) }], }; } - src/server.ts:1017-1023 (helper)The errResult() helper used in the catch block of konsulto_whoami to surface errors back to the MCP client.
function errResult(err: unknown) { const message = err instanceof Error ? err.message : String(err); return { isError: true, content: [{ type: 'text' as const, text: `Error: ${message}` }], }; }