ScholarMCP
by lstudlo

OpenCode

Connect ScholarMCP to OpenCode with the MCP CLI flow and JSON fallback config.

This guide shows how to attach ScholarMCP to OpenCode using its MCP management commands and config file format.

Official references:

What OpenCode Supports

  • MCP server management with opencode mcp add and opencode mcp list
  • local stdio servers launched from an explicit command array
  • manual fallback in ~/.config/opencode/opencode.json

Install or Verify the OpenCode CLI

Verify that OpenCode and its MCP command group are installed:

opencode --version
opencode mcp --help

Add ScholarMCP with the OpenCode CLI

OpenCode exposes opencode mcp add, but the current CLI help does not document a stable non-interactive argument format for local stdio servers. Use the interactive flow:

opencode mcp add

When prompted, configure ScholarMCP as:

  1. Name: scholar_mcp
  2. Server type: local
  3. Command:
    • npm-based: npx -y scholar-mcp --transport=stdio
    • repo-local: pnpm --filter scholar-mcp dev:stdio
  4. Enabled: true
  5. Environment variables:
    • SCHOLAR_MCP_TRANSPORT=stdio
    • SCHOLAR_REQUEST_DELAY_MS=350
    • RESEARCH_ALLOW_REMOTE_PDFS=true
    • RESEARCH_ALLOW_LOCAL_PDFS=true

Verify the Registration

List configured MCP servers:

opencode mcp list

Confirm that scholar_mcp appears and is enabled.

Manual Fallback If opencode mcp add Fails

Add this entry to ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "scholar_mcp": {
      "type": "local",
      "command": ["npx", "-y", "scholar-mcp", "--transport=stdio"],
      "enabled": true,
      "environment": {
        "SCHOLAR_MCP_TRANSPORT": "stdio",
        "SCHOLAR_REQUEST_DELAY_MS": "350",
        "RESEARCH_ALLOW_REMOTE_PDFS": "true",
        "RESEARCH_ALLOW_LOCAL_PDFS": "true"
      }
    }
  }
}

Restart OpenCode, then run:

opencode mcp list

If the entry exists but does not launch correctly, compare the stored command and environment values against /reference/troubleshooting/.

Run from Repo Instead of npm

If you want the latest local ScholarMCP code, replace the command array with the repo-local launcher:

pnpm --filter scholar-mcp dev:stdio

In JSON config, that becomes:

["pnpm", "--filter", "scholar-mcp", "dev:stdio"]

Start typing to search