Skip to main content
Glama

get-associated-opportunities

Retrieve opportunities linked to a specific account in Dynamics 365 using the provided account ID. Facilitates efficient account-related opportunity management.

Instructions

Fetch opportunities for a given account from Dynamics 365

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes

Implementation Reference

  • MCP tool handler function that extracts accountId from request, calls Dynamics365.getAssociatedOpportunities, formats response as text content, handles errors.
    async (req) => { try { const response = await d365.getAssociatedOpportunities(req.accountId); 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, }; } }
  • Input schema using Zod: requires 'accountId' as string.
    { accountId: z.string() },
  • src/tools.ts:72-101 (registration)
    Registration of the 'get-associated-opportunities' tool via server.tool() with name, description, schema, and handler function.
    server.tool( "get-associated-opportunities", "Fetch opportunities for a given account from Dynamics 365", { accountId: z.string() }, async (req) => { try { const response = await d365.getAssociatedOpportunities(req.accountId); 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, }; } } );
  • Helper method in Dynamics365 class implementing the core logic: OData query to fetch opportunities associated with the given accountId via _customerid_value filter.
    public async getAssociatedOpportunities(accountId: string): Promise<any> { if (!accountId) { throw new Error("Account ID is required to fetch opportunities."); } const endpoint = `api/data/v9.2/opportunities?$filter=_customerid_value eq ${accountId}`; return this.makeApiRequest(endpoint, "GET"); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/srikanth-paladugula/mcp-dynamics365-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server