get-accounts
Retrieve a list of all available Autodesk Construction Cloud accounts via the APS MCP Server, enabling access to account details for managing and integrating platform services.
Instructions
List all available Autodesk Construction Cloud accounts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-accounts.ts:7-25 (handler)The main handler for the 'get-accounts' tool, which fetches and returns a list of available Autodesk Construction Cloud accounts (hubs) using the DataManagementClient.export const getAccounts: Tool<typeof schema> = { title: "get-accounts", description: "List all available Autodesk Construction Cloud accounts", schema, callback: async () => { const accessToken = await getAccessToken(["data:read"]); const dataManagementClient = new DataManagementClient(); const hubs = await dataManagementClient.getHubs({ accessToken }); if (!hubs.data) { throw new Error("No accounts found"); } return { content: hubs.data.map((hub) => ({ type: "text", text: JSON.stringify({ id: hub.id, name: hub.attributes?.name }) })) }; } };
- src/tools/get-accounts.ts:5-5 (schema)Empty schema indicating no input parameters required for the get-accounts tool.const schema = {};
- src/server.ts:12-14 (registration)Registers all tools from the tools module, including 'get-accounts', with the MCP server.for (const tool of Object.values(tools)) { server.tool(tool.title, tool.description, tool.schema, tool.callback); }
- src/tools/index.ts:1-1 (registration)Re-exports the getAccounts tool object for aggregation in tools/index.ts.export { getAccounts } from "./get-accounts.js";
- src/tools/common.ts:15-27 (helper)Shared helper function to retrieve a cached access token for APS API scopes, used in the get-accounts handler.export async function getAccessToken(scopes: string[]): Promise<string> { const cacheKey = scopes.join("+"); let credentials = credentialsCache.get(cacheKey); if (!credentials || credentials.expiresAt < Date.now()) { const { access_token, expires_in } = await getServiceAccountAccessToken(APS_CLIENT_ID!, APS_CLIENT_SECRET!, APS_SA_ID!, APS_SA_KEY_ID!, APS_SA_PRIVATE_KEY!, scopes); credentials = { accessToken: access_token, expiresAt: Date.now() + expires_in * 1000 }; credentialsCache.set(cacheKey, credentials); } return credentials.accessToken; }