From 0b853903e6b52fee83eb9c2f64f41559289c06a5 Mon Sep 17 00:00:00 2001 From: dhruv7539 Date: Fri, 27 Feb 2026 11:53:03 -0800 Subject: [PATCH] Namespace MCP tool names with provider prefix and keep legacy aliases --- packages/local-mcp-server/README.md | 10 +++--- packages/local-mcp-server/src/server.ts | 32 ++++++++++++++++--- .../local-mcp-server/src/test/server.test.ts | 25 +++++++++++++++ 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/packages/local-mcp-server/README.md b/packages/local-mcp-server/README.md index 2401c9dc..5ce523f8 100644 --- a/packages/local-mcp-server/README.md +++ b/packages/local-mcp-server/README.md @@ -19,22 +19,24 @@ The Glean MCP Server is a [Model Context Protocol (MCP)](https://modelcontextpro ## Tools -- ### company_search +- ### glean_company_search Search Glean's content index using the Glean Search API. This tool allows you to query Glean's content index with various filtering and configuration options. -- ### chat +- ### glean_chat Interact with Glean's AI assistant using the Glean Chat API. This tool allows you to have conversational interactions with Glean's AI, including support for message history, citations, and various configuration options. -- ### people_profile_search +- ### glean_people_profile_search Search Glean's People directory to find employee information. -- ### read_documents +- ### glean_read_documents Read documents from Glean by providing document IDs or URLs. This tool allows you to retrieve the full content of specific documents for detailed analysis or reference. +For backwards compatibility, legacy tool names (`company_search`, `chat`, `people_profile_search`, and `read_documents`) are still accepted by the server when invoked directly. + ## MCP Client Configuration To configure this MCP server in your MCP client (such as Claude Desktop, Windsurf, Cursor, etc.), run [@gleanwork/configure-mcp-server](https://github.com/gleanwork/configure-mcp-server) passing in your client, token and instance. diff --git a/packages/local-mcp-server/src/server.ts b/packages/local-mcp-server/src/server.ts index 9e8a43a1..d023ba13 100644 --- a/packages/local-mcp-server/src/server.ts +++ b/packages/local-mcp-server/src/server.ts @@ -6,10 +6,10 @@ * for communication and implements the MCP specification for tool discovery and execution. * * The server exposes four tools: - * 1. company_search - Search across Glean's indexed content - * 2. people_profile_search - Search for people profiles inside the company - * 3. chat - Converse with Glean's AI assistant - * 4. read_documents - Retrieve documents by ID or URL + * 1. glean_company_search - Search across Glean's indexed content + * 2. glean_people_profile_search - Search for people profiles inside the company + * 3. glean_chat - Converse with Glean's AI assistant + * 4. glean_read_documents - Retrieve documents by ID or URL */ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; @@ -31,12 +31,34 @@ import { import { VERSION } from './common/version.js'; export const TOOL_NAMES = { + companySearch: 'glean_company_search', + peopleProfileSearch: 'glean_people_profile_search', + chat: 'glean_chat', + readDocuments: 'glean_read_documents', +}; + +const LEGACY_TOOL_NAMES = { companySearch: 'company_search', peopleProfileSearch: 'people_profile_search', chat: 'chat', readDocuments: 'read_documents', }; +const TOOL_NAME_ALIASES = new Map([ + [TOOL_NAMES.companySearch, TOOL_NAMES.companySearch], + [LEGACY_TOOL_NAMES.companySearch, TOOL_NAMES.companySearch], + [TOOL_NAMES.peopleProfileSearch, TOOL_NAMES.peopleProfileSearch], + [LEGACY_TOOL_NAMES.peopleProfileSearch, TOOL_NAMES.peopleProfileSearch], + [TOOL_NAMES.chat, TOOL_NAMES.chat], + [LEGACY_TOOL_NAMES.chat, TOOL_NAMES.chat], + [TOOL_NAMES.readDocuments, TOOL_NAMES.readDocuments], + [LEGACY_TOOL_NAMES.readDocuments, TOOL_NAMES.readDocuments], +]); + +function normalizeToolName(toolName: string): string { + return TOOL_NAME_ALIASES.get(toolName) ?? toolName; +} + /** * MCP server instance configured for Glean's implementation. * Supports tool discovery and execution through the MCP protocol. @@ -134,7 +156,7 @@ export async function callToolHandler(request: CallToolRequest) { throw new Error('Arguments are required'); } - switch (request.params.name) { + switch (normalizeToolName(request.params.name)) { case TOOL_NAMES.companySearch: { const args = search.ToolSearchSchema.parse(request.params.arguments); const result = await search.search(args); diff --git a/packages/local-mcp-server/src/test/server.test.ts b/packages/local-mcp-server/src/test/server.test.ts index ad334dbe..b6a65724 100644 --- a/packages/local-mcp-server/src/test/server.test.ts +++ b/packages/local-mcp-server/src/test/server.test.ts @@ -155,6 +155,31 @@ describe('MCP Server Handlers (integration)', () => { ); }); + it('accepts legacy tool aliases for backwards compatibility', async () => { + const req = CallToolRequestSchema.parse({ + method: 'tools/call', + id: '6-legacy', + jsonrpc: '2.0', + params: { + name: 'chat', + arguments: { message: 'hello' }, + }, + }); + + const res = await callToolHandler(req); + expect(res).toMatchInlineSnapshot(` + { + "content": [ + { + "text": "GLEAN_AI (UPDATE): Search company knowledge", + "type": "text", + }, + ], + "isError": false, + } + `); + }); + it('executes people_profile_search with filters only', async () => { const req = CallToolRequestSchema.parse({ method: 'tools/call',