Description
Environment
- OpenCode: latest (oh-my-opencode v3.17.15)
- MCP server: obsidian-mcp-server@3.1.5 (cyanheads/obsidian-mcp-server, npm)
- OS: Windows
Steps to reproduce
- Configure obsidian-mcp-server as an MCP server (stdio transport)
- Call
obsidian_patch_note with valid nested parameters:
- target: { type: "path", path: "SomeFile.md" }
- section: { type: "heading", target: "SectionName" }
- operation: "append"
- content: "new content"
- Call
obsidian_append_to_note with:
- target: { type: "path", path: "SomeFile.md" }
- section: { type: "heading", target: "SectionName" } (optional)
- content: "new content"
Expected behavior
Both calls should succeed with properly structured nested parameters matching the server's declared input schema.
Actual behavior
Both calls fail with -32602 Invalid params. The error messages demand flat top-level fields that are actually nested inside discriminated union objects, e.g.:
required property 'path' (path is inside target, not top-level)
required property 'sectionTargeted' (this is an output field, not an input field)
Which tools are affected
obsidian_patch_note — has target (discriminated union) + section (nested object)
obsidian_append_to_note — has target (discriminated union) + optional section (nested object)
Which tools work correctly
obsidian_replace_in_note — all flat parameters
obsidian_write_note — single nested target
obsidian_get_note — single nested target
obsidian_list_notes — all flat parameters
Hypothesis
OpenCode's host layer is incorrectly flattening Zod discriminated-union schemas when a tool has two or more nested-object parameters, then validating calls against the flattened (incorrect) schema instead of the server's actual schema.
Server schema (for reference)
From obsidian-mcp-server@3.1.5 source (obsidian-patch-note.tool.js):
input: z.object({
target: TargetSchema, // discriminated union: {type:"path",path} | {type:"active"} | {type:"periodic",...}
section: SectionSchema, // nested object: {type: "heading"|"block"|"frontmatter", target: string}
operation: z.enum('append', 'prepend', 'replace'),
content: z.string(),
})
Workaround
Using obsidian_replace_in_note (literal/regex search-replace) in place of obsidian_patch_note and obsidian_append_to_note works correctly.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
Environment
Steps to reproduce
obsidian_patch_notewith valid nested parameters:obsidian_append_to_notewith:Expected behavior
Both calls should succeed with properly structured nested parameters matching the server's declared input schema.
Actual behavior
Both calls fail with
-32602 Invalid params. The error messages demand flat top-level fields that are actually nested inside discriminated union objects, e.g.:required property 'path'(path is insidetarget, not top-level)required property 'sectionTargeted'(this is an output field, not an input field)Which tools are affected
obsidian_patch_note— hastarget(discriminated union) +section(nested object)obsidian_append_to_note— hastarget(discriminated union) + optionalsection(nested object)Which tools work correctly
obsidian_replace_in_note— all flat parametersobsidian_write_note— single nested targetobsidian_get_note— single nested targetobsidian_list_notes— all flat parametersHypothesis
OpenCode's host layer is incorrectly flattening Zod discriminated-union schemas when a tool has two or more nested-object parameters, then validating calls against the flattened (incorrect) schema instead of the server's actual schema.
Server schema (for reference)
From obsidian-mcp-server@3.1.5 source (
obsidian-patch-note.tool.js):input: z.object({
target: TargetSchema, // discriminated union: {type:"path",path} | {type:"active"} | {type:"periodic",...}
section: SectionSchema, // nested object: {type: "heading"|"block"|"frontmatter", target: string}
operation: z.enum('append', 'prepend', 'replace'),
content: z.string(),
})
Workaround
Using
obsidian_replace_in_note(literal/regex search-replace) in place ofobsidian_patch_noteandobsidian_append_to_noteworks correctly.Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response