node-server #10

Merged
Peter.Morton merged 7 commits from node-server into main 2026-04-30 20:46:52 -05:00

7 Commits

Author SHA1 Message Date
253c3a327b chore: bump version to 1.2.0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 20:12:09 -05:00
76b4aed508 fix: read binary files via native FS instead of Obsidian CLI
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>
2026-04-30 20:08:35 -05:00
8b651d379a feat: add HTTP server transport for MCP
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>
2026-04-30 19:41:51 -05:00
3948cd6966 chore: bump version to 1.1.9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 19:32:52 -05:00
cef658ce19 fix: return images as MCP image content type per spec
Images (PNG, JPG, GIF, WEBP, SVG) now returned as { type: 'image', data, mimeType }
per https://modelcontextprotocol.io/specification/2025-11-25/server/tools#image-content
Other binary files continue using embedded resource format { type: 'resource', ... }
Added audio content type to ToolOutput union for future use

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 19:31:47 -05:00
31744d01a1 chore: bump version to 1.1.8 and update CHANGELOG
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-30 18:53:50 -05:00
6ee26f1ad8 fix: return binary files as MCP embedded resource instead of BASE64 prefix fixes #9
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>
2026-04-30 18:52:57 -05:00