Skip to main content
Glama

hubspot-get-user-details

Authenticates the HubSpot access token to retrieve user details, including permissions, account information, and API scopes, ensuring proper access before HubSpot 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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • The handler class UserCredentialsTool that extends BaseTool and implements the process method to fetch HubSpot token info, owner details, and account information using the HubSpotClient.
    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, }; } } }
  • Defines the Zod schema for input (empty object) and the full ToolDefinition object including name 'hubspot-get-user-details', description, inputSchema, 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, }, };
  • Imports the UserCredentialsTool and registers a new instance with the tool registry via registerTool.
    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());

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