create-account
Use this tool to generate a new account in Dynamics 365 via the MCP server, enabling efficient account management through structured data input.
Instructions
Create a new account in Dynamics 365
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountData | Yes |
Implementation Reference
- src/tools.ts:108-132 (handler)The core handler function for the "create-account" tool. It destructures accountData from input params, calls the Dynamics365.createAccount helper, and returns the formatted JSON response or an error message.async (params) => { try { const { accountData } = params; const response = await d365.createAccount(accountData); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : "Unknown error" }, please check your input and try again.`, }, ], isError: true, }; }
- src/tools.ts:107-107 (schema)Zod-based input schema for the tool, defining a required 'accountData' parameter as an empty object schema (allows any object structure).{ accountData: z.object({}) },
- src/tools.ts:104-133 (registration)Registration of the "create-account" tool using McpServer.tool(), specifying name, description, input schema, and inline handler function within registerTools.server.tool( "create-account", "Create a new account in Dynamics 365", { accountData: z.object({}) }, async (params) => { try { const { accountData } = params; const response = await d365.createAccount(accountData); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : "Unknown error" }, please check your input and try again.`, }, ], isError: true, }; } }
- src/main.ts:214-221 (helper)Helper method in the Dynamics365 class that validates input and delegates to makeApiRequest for POSTing account data to the Dynamics 365 Web API endpoint /api/data/v9.2/accounts.public async createAccount(accountData: any): Promise<any> { if (!accountData) { throw new Error("Account data is required to create an account."); } const endpoint = "api/data/v9.2/accounts"; return this.makeApiRequest(endpoint, "POST", accountData); }