harvest_get_current_user
Retrieve authenticated user details from the Harvest time tracking system to verify identity and access permissions.
Instructions
Get information about the authenticated user. Use about {"tool": "harvest_get_current_user"} for detailed response format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/harvest-client.ts:146-148 (handler)The core handler function that executes the tool logic by making an authenticated API request to Harvest's /users/me endpoint to retrieve the current user's information.async getCurrentUser() { return this.makeRequest('/users/me'); }
- src/index.ts:211-220 (handler)MCP server dispatcher case for the tool that invokes the HarvestClient method and formats the JSON response.case 'harvest_get_current_user': const currentUser = await harvestClient.getCurrentUser(); return { content: [ { type: 'text', text: JSON.stringify(currentUser, null, 2), }, ], };
- src/tools.ts:144-151 (schema)Tool schema definition specifying the name, description, and input schema (no parameters required). This is part of the tools array used for MCP tool listing.{ name: 'harvest_get_current_user', description: 'Get information about the authenticated user. Use about {"tool": "harvest_get_current_user"} for detailed response format.', inputSchema: { type: 'object', properties: {} } },
- src/index.ts:69-73 (registration)Registration of all tools (including harvest_get_current_user) by providing the tools array in response to ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: tools, }; });
- src/harvest-client.ts:27-57 (helper)Helper method used by getCurrentUser to make authenticated HTTP requests to the Harvest API.private async makeRequest(endpoint: string, options: RequestInit = {}) { const url = `${this.baseUrl}${endpoint}`; const response = await fetch(url, { ...options, headers: { 'Authorization': `Bearer ${this.accessToken}`, 'Harvest-Account-ID': this.accountId, 'User-Agent': this.userAgent, 'Content-Type': 'application/json', ...options.headers, }, }); if (!response.ok) { let errorMessage = `Harvest API error: ${response.status} ${response.statusText}`; try { const errorBody = await response.json() as any; if (errorBody.message) { errorMessage += ` - ${errorBody.message}`; } } catch { // If we can't parse the error response, use the basic error message } throw new Error(errorMessage); } return response.json(); }