Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/mcp/e2e/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import {
const EXPECTED_TOOLS = [
"add_memory",
"fetch-graph-data",
"getDocument",
Comment thread
MaheshtheDev marked this conversation as resolved.
"get_document",
"get_profile",
"guided-save",
"listDocuments",
"listMemories",
"listSpaces",
"list_documents",
"list_memories",
"list_spaces",
Expand All @@ -23,6 +27,7 @@ const EXPECTED_TOOLS = [
"select-space",
"set-active-tag",
"upload-file",
"whoAmI",
"who_am_i",
]
const describeWithAuth = describe.skipIf(!OAUTH_CREDENTIALS_AVAILABLE)
Expand Down
41 changes: 40 additions & 1 deletion apps/mcp/src/server/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,46 @@ import type { ToolDeps } from "./types"
import * as uploadFile from "./upload-file"
import * as whoAmI from "./who-am-i"

export function registerAllTools(deps: ToolDeps) {
// Renamed to snake_case in #1665; clients with a cached tool list still call the old names.
Comment thread
MaheshtheDev marked this conversation as resolved.
// Remove once PostHog shows ~0 $mcp_tool_call events for these names for 2 weeks.
const LEGACY_TOOL_NAMES: Record<string, string> = {
Comment thread
MaheshtheDev marked this conversation as resolved.
get_document: "getDocument",
list_spaces: "listSpaces",
list_documents: "listDocuments",
list_memories: "listMemories",
who_am_i: "whoAmI",
}

type LooseRegisterTool = (
name: string,
config: { title?: string; description?: string },
cb: unknown,
) => ReturnType<ToolDeps["server"]["registerTool"]>

// Aliases must stay listed: ChatGPT rejects calls to tools missing from tools/list.
function withLegacyToolNames(server: ToolDeps["server"]): ToolDeps["server"] {
const register = server.registerTool.bind(server) as LooseRegisterTool
const registerTool: LooseRegisterTool = (name, config, cb) => {
const tool = register(name, config, cb)
const legacyName = LEGACY_TOOL_NAMES[name]
if (legacyName) {
register(
legacyName,
{
...config,
Comment thread
MaheshtheDev marked this conversation as resolved.
...(config.title ? { title: `${config.title} (deprecated)` } : {}),
description: `Deprecated: use ${name}.`,
},
cb,
)
}
return tool
}
return { registerTool: registerTool as ToolDeps["server"]["registerTool"] }
}

export function registerAllTools(toolDeps: ToolDeps) {
const deps = { ...toolDeps, server: withLegacyToolNames(toolDeps.server) }
searchMemory.register(deps)
getProfile.register(deps)
listDocuments.register(deps)
Expand Down
Loading