/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { buildDetail } from "../../intent/build-detail.js"; import { type PrimeDeps } from "../../lib/prime-schema.js"; import { DETAIL_INPUT } from "../../schemas/input-schemas.js"; import { runTool } from "../../schemas/tool-adapter.js"; export interface SfGqlDetailToolOptions { primeDeps?: PrimeDeps; } const inputSchema = DETAIL_INPUT; export function registerSfGqlDetailTool( server: McpServer, opts: SfGqlDetailToolOptions = {}, ): void { server.registerTool( "sf_gql_detail", { description: [ "Build a UIAPI single-record detail query for fetching one specific Salesforce record by its Id.", "Use this tool when you already know the record Id and need to retrieve detailed field data, parent relationships, or child relationships for that single record.", "The query is automatically bound to an ID variable; you do NOT need to provide filtering parameters.", "For listing multiple records or searching with filters, use sf_gql_list instead.", "", "Examples:", ' - Minimal: { org: "ebikes", object: "Account", fields: ["Id", "Name", "Industry"] }', ' - With parent fields: { org: "ebikes", object: "Case", fields: ["Id", "Subject"], parentFields: ["Account.Name", "Owner.Name"] }', ' - With child relationships and a custom id variable name: { org: "ebikes", object: "Account", fields: ["Id"], idVariable: "accountId", childRelationships: [{ relationshipName: "Contacts", fields: ["LastName"], first: 5 }] }', ].join("\n"), inputSchema, }, async (args) => runTool(() => buildDetail(args, opts.primeDeps)), ); }