fix: tools/list handler now returns proper tool metadata

Issue: The registerTool method was receiving description and inputSchema
parameters but marking them as unused (_description, _inputSchema) and
not storing them with the handler. This caused tools/list to return
tools without their description and inputSchema properties.

Fix: Remove underscore prefixes and explicitly set these properties on
the handler object before storing it in the tools Map.

Now tools/list will properly return:
- name: Tool name
- description: Tool description (from registerTool call)
- inputSchema: Tool input schema (from registerTool call)

This ensures MCP clients can see proper tool documentation and schemas.

Files changed:
- src/server.ts: Fixed registerTool to preserve metadata

Build:  0 errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-22 12:43:54 -05:00
parent c577c07877
commit 23e307a7a9
2 changed files with 7 additions and 3 deletions

View File

@@ -42,10 +42,14 @@ export class ObsidianMCPServer {
*/ */
registerTool( registerTool(
name: string, name: string,
_description: string, description: string,
_inputSchema: Record<string, unknown>, inputSchema: Record<string, unknown>,
handler: ToolHandler handler: ToolHandler
): void { ): void {
// Ensure handler has description and inputSchema
handler.description = description;
handler.inputSchema = inputSchema;
this.tools.set(name, handler); this.tools.set(name, handler);
logger.debug('Registered tool', { name }); logger.debug('Registered tool', { name });
} }

View File

@@ -20,7 +20,7 @@ export async function registerSearchTools(server: ObsidianMCPServer): Promise<vo
// T046: Search tool // T046: Search tool
server.registerTool( server.registerTool(
'obsidian_search', 'obsidian_search',
'Search vault for text. Returns matching files and optionally match counts. Supports path filtering, result limits, case sensitivity, and multiple output formats (text/json).', 'Search vault for text. Returns matching files or optionally match counts using `total` flag. Supports path filtering, result limits, case sensitivity, and multiple output formats (text/json).',
{ type: 'object', properties: {} }, { type: 'object', properties: {} },
createToolHandler( createToolHandler(
'Search vault for text', 'Search vault for text',