update-account
Modify existing account records in Dynamics 365 by providing account ID and updated data fields.
Instructions
Update an existing account in Dynamics 365
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"accountId": "<accountId>",
"accountData": "<accountData>"
},
"name": "update-account"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | ||
| accountData | Yes |
Implementation Reference
- src/tools.ts:144-170 (handler)The handler function registered for the 'update-account' MCP tool. It extracts parameters, invokes the Dynamics365 updateAccount method, formats the response as text content, and handles errors appropriately.
async (params) => { try { const { accountId, accountData } = params; const response = await d365.updateAccount(accountId, 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:140-143 (schema)Zod schema defining the input parameters for the 'update-account' tool: accountId as string and accountData as object.
{ accountId: z.string(), accountData: z.object({}), }, - src/tools.ts:136-170 (registration)Registration of the 'update-account' tool using server.tool(), including name, description, schema, and handler function.
// Register the "update-account" tool server.tool( "update-account", "Update an existing account in Dynamics 365", { accountId: z.string(), accountData: z.object({}), }, async (params) => { try { const { accountId, accountData } = params; const response = await d365.updateAccount(accountId, 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:229-243 (helper)Helper method in Dynamics365 class that performs the actual account update by making a PATCH request to the Dynamics 365 Web API endpoint.
public async updateAccount( accountId: string, accountData: any ): Promise<any> { if (!accountId) { throw new Error("Account ID is required to update an account."); } if (!accountData) { throw new Error("Account data is required to update an account."); } const endpoint = `api/data/v9.2/accounts(${accountId})`; return this.makeApiRequest(endpoint, "PATCH", accountData); }