get-projects
Retrieve a list of all available projects within an Autodesk Construction Cloud account using the APS MCP Server. Simplify project management and access control by querying relevant project data.
Instructions
List all available projects in an Autodesk Construction Cloud account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes |
Implementation Reference
- src/tools/get-projects.ts:14-28 (handler)Handler function that authenticates using getAccessToken and retrieves projects for the specified accountId using Autodesk Platform Services DataManagementClient.callback: async ({ accountId }) => { // TODO: add pagination support const accessToken = await getAccessToken(["data:read"]); const dataManagementClient = new DataManagementClient(); const projects = await dataManagementClient.getHubProjects(accountId, { accessToken }); if (!projects.data) { throw new Error("No projects found"); } return { content: projects.data.map((project) => ({ type: "text", text: JSON.stringify({ id: project.id, name: project.attributes?.name }) })) }; }
- src/tools/get-projects.ts:6-8 (schema)Zod schema for input validation, requiring a non-empty string accountId.const schema = { accountId: z.string().nonempty() };
- src/server.ts:12-14 (registration)Registers all tools from the tools module, including 'get-projects', with the MCP server by calling server.tool for each.for (const tool of Object.values(tools)) { server.tool(tool.title, tool.description, tool.schema, tool.callback); }
- src/tools/index.ts:2-2 (registration)Barrel export that includes the getProjects tool in the tools index for server import.export { getProjects } from "./get-projects.js";
- src/tools/common.ts:15-27 (helper)Shared helper function used by the handler to obtain and cache APS access tokens based on scopes.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; }