Skip to content

MCP resources mimeType errors #8920

@dan-kwiat

Description

@dan-kwiat

Description

It seems that only MCP resources with mimeType text/plain are supported.

E.g. take a basic MCP server with a singe resource:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
const server = new McpServer(...)

const name = "my-file.md"
const uri = "file:///docs/my-file.md"
const mimeType = "text/markdown"
server.registerResource(
  name,
  uri,
  { mimeType, description: "" }, // <-- this results in opencode error if mimeType !== "text/plain"
  async () => {
    return {
      contents: [{ uri, text: "# Some Markdown Content", mimeType }], // <-- this mimeType seems to be ignored by opencode
    }
  }
)

After connecting to the server in opencode and selecting the resource with @file:///docs/my-file.md we get:

AI_DownloadError: Failed to download file:///docs/my-file.md: Error: ENOENT: no such file or directory, open '/docs/my-file.md'

And the same error with mimeType inode/directory. But it works if the server has mimeType text/plain.

Plugins

None

OpenCode version

1.1.23

Steps to reproduce

  1. Run a minimal MCP server which exposes a resource with mimeType text/markdown, as above
  2. Connect the MCP server to opencode
  3. Try to @ the MCP resource in opencode

Screenshot and/or share link

No response

Operating System

macOS

Terminal

Ghostty

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions