Skip to main content
Glama
standardbeagle

Harvest MCP Server

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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');
    }
  • 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),
          },
        ],
      };
  • 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,
      };
    });
  • 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();
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/standardbeagle/harvest-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server