Skip to main content
Glama
ajaystream

HubSpot MCP Server

by ajaystream

hubspot-get-user-details

Read-onlyIdempotent

Authenticate and analyze HubSpot access tokens to verify user identity, permissions, and account details before performing CRM operations.

Instructions

🎯 Purpose
  1. Authenticates and analyzes the current HubSpot access token, providing context about the user's permissions and account details.

🧭 Usage Guidance:
  1. This tool must be used before performing any operations with Hubspot tools to determine the identity of the user, and permissions they have on their Hubspot account.

📦 Returns:
  1. User ID, Hub ID, App ID, token type, a comprehensive list of authorized API scopes, and detailed owner information, and account information.
  2. The uiDomain and hubId can be used to construct URLs to the HubSpot UI for the user.
  3. If the user is an owner, the ownerId will help identify objects that are owned by the user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • UserCredentialsTool class implementing the tool handler logic. Fetches HubSpot token info, owner details, and account info using the HubSpotClient and returns formatted text content.
    export class UserCredentialsTool extends BaseTool {
        client;
        constructor() {
            super(TokenInfoSchema, ToolDefinition);
            this.client = new HubSpotClient();
        }
        // Implement the process method
        async process(_args) {
            const accessToken = process.env.PRIVATE_APP_ACCESS_TOKEN || process.env.HUBSPOT_ACCESS_TOKEN;
            if (!accessToken) {
                return {
                    content: [
                        {
                            type: 'text',
                            text: 'Error: PRIVATE_APP_ACCESS_TOKEN not found in environment variables',
                        },
                    ],
                    isError: true,
                };
            }
            try {
                const [tokenInfo, accountInfo] = await Promise.all([
                    this.client.post('/oauth/v2/private-apps/get/access-token-info', {
                        body: { tokenKey: accessToken },
                    }),
                    this.client.get('/account-info/v3/details').catch(() => null),
                ]);
                const ownerInfo = await this.client
                    .get(`/crm/v3/owners/${tokenInfo.userId}?idProperty=userId&archived=false`)
                    .catch(() => null);
                return {
                    content: [
                        { type: 'text', text: '- Token Info: ' + JSON.stringify(tokenInfo, null, 2) },
                        { type: 'text', text: '- OwnerInfo: ' + JSON.stringify(ownerInfo, null, 2) },
                        { type: 'text', text: '- AccountInfo: ' + JSON.stringify(accountInfo, null, 2) },
                    ],
                };
            }
            catch (error) {
                return {
                    content: [
                        {
                            type: 'text',
                            text: `Error retrieving token, owner, and account information. ${error instanceof Error ? error.message : String(error)}
                `,
                        },
                    ],
                    isError: true,
                };
            }
        }
    }
  • Zod input schema (empty object, no params) and ToolDefinition with name, description, inputSchema converted to JSON schema, and annotations.
    const TokenInfoSchema = z.object({});
    const ToolDefinition = {
        name: 'hubspot-get-user-details',
        description: `
        🎯 Purpose
          1. Authenticates and analyzes the current HubSpot access token, providing context about the user's permissions and account details.
    
        🧭 Usage Guidance:
          1. This tool must be used before performing any operations with Hubspot tools to determine the identity of the user, and permissions they have on their Hubspot account.
    
        📦 Returns:
          1. User ID, Hub ID, App ID, token type, a comprehensive list of authorized API scopes, and detailed owner information, and account information.
          2. The uiDomain and hubId can be used to construct URLs to the HubSpot UI for the user.
          3. If the user is an owner, the ownerId will help identify objects that are owned by the user.
      `,
        inputSchema: zodToJsonSchema(TokenInfoSchema),
        annotations: {
            title: 'Get User Details',
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: true,
        },
    };
  • Import of UserCredentialsTool and registration via registerTool(new UserCredentialsTool()); in the tools registry.
    import { UserCredentialsTool } from './oauth/getUserDetailsTool.js';
    import { ObjectListTool } from './objects/listObjectsTool.js';
    import { ObjectSearchTool } from './objects/searchObjectsTool.js';
    import { BatchCreateAssociationsTool } from './associations/batchCreateAssociationsTool.js';
    import { AssociationSchemaDefinitionTool } from './associations/getAssociationDefinitionsTool.js';
    import { AssociationsListTool } from './associations/listAssociationsTool.js';
    import { BatchCreateObjectsTool } from './objects/batchCreateObjectsTool.js';
    import { BatchUpdateObjectsTool } from './objects/batchUpdateObjectsTool.js';
    import { BatchReadObjectsTool } from './objects/batchReadObjectsTool.js';
    import { PropertiesListTool } from './properties/listPropertiesTool.js';
    import { GetPropertyTool } from './properties/getPropertyTool.js';
    import { CreatePropertyTool } from './properties/createPropertyTool.js';
    import { UpdatePropertyTool } from './properties/updatePropertyTool.js';
    import { CreateEngagementTool } from './engagements/createEngagementTool.js';
    import { GetEngagementTool } from './engagements/getEngagementTool.js';
    import { UpdateEngagementTool } from './engagements/updateEngagementTool.js';
    import { FeedbackLinkTool } from './links/feedbackLinkTool.js';
    import { GetSchemasTool } from './objects/getSchemaTool.js';
    import { GetHubspotLinkTool } from './links/getHubspotLinkTool.js';
    import { WorkflowsListTool } from './workflows/listWorkflowsTool.js';
    import { GetWorkflowTool } from './workflows/getWorkflowTool.js';
    import { RefreshTokenTool } from './oauth/refreshTokenTool.js';
    // Register all tools
    registerTool(new UserCredentialsTool());
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate this is a read-only, non-destructive, idempotent operation with open-world semantics. The description adds valuable context beyond this: it explains that the tool authenticates and analyzes tokens, provides permission context, and returns specific data like user ID, hub ID, and API scopes. It also mentions practical uses like constructing HubSpot UI URLs. No contradiction with annotations exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Purpose, Usage Guidance, Returns) and uses bullet points efficiently. Every sentence adds value: the purpose statement is specific, the usage guidance is directive, and the returns section explains what data is provided and how it can be used. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with comprehensive annotations (readOnlyHint, openWorldHint, idempotentHint, destructiveHint) but no output schema, the description provides excellent context. It explains the tool's purpose, when to use it, and details the return values including user ID, hub ID, API scopes, and practical applications. This gives the agent everything needed to understand and invoke this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's purpose and output. This meets the baseline expectation for a zero-parameter tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool's purpose: 'Authenticates and analyzes the current HubSpot access token, providing context about the user's permissions and account details.' This clearly distinguishes it from sibling tools (which focus on objects, properties, workflows, etc.) by specifying it's about user authentication and permission analysis rather than data operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'This tool must be used before performing any operations with Hubspot tools to determine the identity of the user, and permissions they have on their Hubspot account.' This tells the agent exactly when to use it (as a prerequisite) and why, distinguishing it from all sibling tools that perform actual HubSpot operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ajaystream/hubspot-mcp-custom'

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