Skip to main content
Glama
srikanth-paladugula

Dynamics 365 MCP Server

get-associated-opportunities

Fetch sales opportunities linked to a specific account in Dynamics 365 to analyze customer potential and track business deals.

Instructions

Fetch opportunities for a given account from Dynamics 365

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes

Implementation Reference

  • MCP tool handler: fetches opportunities via Dynamics365 client, formats as JSON text response or error message.
    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: requires 'accountId' as string.
    { accountId: z.string() },
  • src/tools.ts:72-101 (registration)
    Registers the MCP tool 'get-associated-opportunities' with description, schema, and handler.
    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,
          };
        }
      }
    );
  • Dynamics365 helper: validates accountId, builds OData filter query for opportunities, delegates to makeApiRequest.
    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");
    }

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-dyamics365-server'

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