fetch-accounts
Retrieve account data from Microsoft Dynamics 365 using the Model Context Protocol server, enabling efficient management and access to account information through natural language interactions.
Instructions
Fetch accounts from Dynamics 365
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:43-69 (handler)The handler function for the 'fetch-accounts' tool. It invokes d365.getAccounts(), formats the response as JSON, and returns it, handling errors appropriately.async () => { try { const response = await d365.getAccounts(); const accounts = JSON.stringify(response.value, null, 2); return { content: [ { type: "text", text: accounts, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : "Unknown error" }, please check your credentials and try again.`, }, ], isError: true, }; } } );
- src/tools.ts:39-69 (registration)Registration of the 'fetch-accounts' tool in the registerTools function using server.tool() with name, description, empty schema, and inline handler.server.tool( "fetch-accounts", "Fetch accounts from Dynamics 365", {}, async () => { try { const response = await d365.getAccounts(); const accounts = JSON.stringify(response.value, null, 2); return { content: [ { type: "text", text: accounts, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : "Unknown error" }, please check your credentials and try again.`, }, ], isError: true, }; } } );
- src/main.ts:180-182 (helper)Helper method getAccounts() in Dynamics365 class that performs the API request to retrieve accounts from Dynamics 365.public async getAccounts(): Promise<any> { return this.makeApiRequest("api/data/v9.2/accounts", "GET"); }