The Obsidian CLI does not support binary file output, causing corrupted
or empty results for images, PDFs, ZIPs, etc.
New approach for binary files (known MIME type from extension):
- Run 'obsidian vault info=path' to get the vault root filesystem path
- If 'file' param: run 'obsidian file file=<name>' and parse the 'path'
field from its output to get the vault-relative path
- If 'path' param: use it directly as the vault-relative path
- Read the file with Node fs.readFile() and return as MCP content
Images -> { type: 'image', data, mimeType }
Other binary -> { type: 'resource', resource: { uri, mimeType, blob } }
Unknown extensions fall through to the CLI with a runtime binary
detection fallback that also uses native FS if triggered.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds src/http-server.ts - a Node.js HTTP entry point that exposes the
MCP implementation via Streamable HTTP transport (POST/GET /mcp) per
the MCP 2025-11-25 specification.
- Uses StreamableHTTPServerTransport (stateless mode) from the MCP SDK
- Port configurable via MCP_PORT env var (default: 3000)
- ObsidianMCPServer.connect() now accepts an optional Transport param
so both stdio (existing) and HTTP (new) modes reuse the same server
- Added 'npm run server' script to start the HTTP server
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous implementation prefixed base64 with "BASE64:" in a text
response. This updates the response to use the proper MCP embedded
resource format:
{ type: "resource", resource: { uri, mimeType, blob } }
Changes:
- types.ts: extend ToolOutput content union to allow resource items
- file-operations.ts:
- getMimeType() maps common extensions to MIME types, falling back
to application/octet-stream
- MIME_TYPES table covers PDF, ZIP, images, Office formats, audio/video
- Binary files are now returned as an EmbeddedResource with:
uri: obsidian://<vault>/<path>
mimeType: detected from file extension
blob: base64-encoded raw bytes from the Buffer
- Tool descriptions updated to document the resource response shape
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>