feat: add proper input schema to obsidian_search tool
Added complete inputSchema definition for the obsidian_search tool
with all parameters matching the Obsidian CLI specification:
Parameters (per 'obsidian search help'):
- query (string, required): Search query text
- path (string, optional): Limit search to folder path
- limit (number, optional): Maximum number of results
- total (boolean, optional): Return match count instead of files
- case (boolean, optional): Case sensitive search
- format (enum, optional): Output format (text|json, default: text)
The inputSchema is now properly exposed via tools/list, enabling:
- Better parameter documentation in MCP clients
- Automatic parameter validation
- Type hints in Claude Desktop
- Improved developer experience
Previously the schema was empty { properties: {} }, now it fully
documents all available parameters with types and descriptions.
Files changed:
- src/tools/search.ts: Added complete inputSchema definition
Build: ✅ 0 errors
Validation: ✅ Manifest passes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -21,10 +21,70 @@ export async function registerSearchTools(server: ObsidianMCPServer): Promise<vo
|
|||||||
server.registerTool(
|
server.registerTool(
|
||||||
'obsidian_search',
|
'obsidian_search',
|
||||||
'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).',
|
'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',
|
||||||
|
required: ['query'],
|
||||||
|
properties: {
|
||||||
|
query: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Search query text (required)',
|
||||||
|
},
|
||||||
|
path: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Limit search to folder path (optional)',
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'Maximum number of results to return (optional)',
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Return match count instead of file list (optional)',
|
||||||
|
},
|
||||||
|
case: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Case sensitive search (optional)',
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
type: 'string',
|
||||||
|
enum: ['text', 'json'],
|
||||||
|
description: 'Output format (optional, default: text)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
createToolHandler(
|
createToolHandler(
|
||||||
'Search vault for text',
|
'Search vault for text',
|
||||||
{ type: 'object', properties: {} },
|
{
|
||||||
|
type: 'object',
|
||||||
|
required: ['query'],
|
||||||
|
properties: {
|
||||||
|
query: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Search query text (required)',
|
||||||
|
},
|
||||||
|
path: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Limit search to folder path (optional)',
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'Maximum number of results to return (optional)',
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Return match count instead of file list (optional)',
|
||||||
|
},
|
||||||
|
case: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Case sensitive search (optional)',
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
type: 'string',
|
||||||
|
enum: ['text', 'json'],
|
||||||
|
description: 'Output format (optional, default: text)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
async (args) => {
|
async (args) => {
|
||||||
const validated = searchSchema.parse(args) as any;
|
const validated = searchSchema.parse(args) as any;
|
||||||
const sanitized = sanitizeParameters(validated) as any;
|
const sanitized = sanitizeParameters(validated) as any;
|
||||||
|
|||||||
Reference in New Issue
Block a user