Skip to content
sy-borgPublic

About

My local MCP servers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

mymcp — local MCP servers

A collection of FastMCP MCP servers, isolated in a virtual environment (Arch Linux ships an externally-managed Python).

Setup

python -m venv .venv
.venv/bin/pip install fastmcp

Running a server

All servers live in servers/, one module per server, and default to stdio transport:

.venv/bin/python -m servers.filesystem

filesystem

File tools (read/write/list/move/delete/search) restricted to configured root directories. Roots come from the colon-separated FILESYSTEM_ROOTS env var; if unset, the current working directory is used.

FILESYSTEM_ROOTS=/home/sa/src:/home/sa/Documents .venv/bin/python -m servers.filesystem

Note: an unrestricted root defeats the purpose — one served project can edit files in anything under the same root.

websearch

Searches the web (DuckDuckGo), Wikipedia, and the Arch Linux repository, and fetches any page — all rendered to plain text through a local text browser (w3m/lynx). Results keep a numbered reference list of URLs, so agents can follow up with fetch_page. Fresh results are not cached; DuckDuckGo's redirect links are unwrapped to real URLs.

Tools: search_web, search_wikipedia, search_arch_packages, fetch_page. Browser selection tries WEBSEARCH_BROWSER → lynx → w3m → links; browser="auto" per call unless overridden. Needs one of w3m, lynx, links installed (e.g. pacman -S w3m).

WEBSEARCH_BROWSER=w3m .venv/bin/python -m servers.websearch

No new Python dependencies: pages are fetched with the standard library and only rendered by the external browser.

memory

Persistent knowledge-graph memory, stored as JSON (entities with observations, plus typed relations between them) at $MEMORY_PATH or $XDG_DATA_HOME/mymcp-memory/graph.json (~/.local/share/mymcp-memory/graph.json by default).

Every tool takes an optional scope. The default scope global uses the path above; any other scope is a project-specific graph stored as a sibling scopes/<scope>.json file. Use global for cross-project knowledge and a project-named scope (e.g. the repo name) for project-specific memory.

Tools: create_entities (merges observations into known entities), create_relations (deduplicated, both ends must exist), add_observations / delete_observations, delete_entities (cascades its relations), read_graph, search_nodes, open_nodes, plus list_scopes and delete_scope for scope housekeeping. Writes are atomic.

.venv/bin/python -m servers.memory

markitdown

Converts files to Markdown (via Microsoft's markitdown) so agents can consume them: PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), HTML, CSV, JSON, XML, EPUB, ZIP listings, images (via OCR), and more. Input files must live under the allowed roots — the same colon-separated FILESYSTEM_ROOTS env var the filesystem server uses (cwd by default), so the two servers interoperate.

Tools: convert_file (path → Markdown, truncated to max_chars), convert_string (in-memory content + file extension → Markdown), list_allowed_roots.

FILESYSTEM_ROOTS=/home/sa/src:/home/sa/Documents .venv/bin/python -m servers.markitdown

Dependency: pip install "markitdown[all]" into .venv (plus python-docx, needed only by smoke_test_markitdown.py to build the test .docx).

Adding another server

  1. Create servers/<name>.py with a FastMCP instance called mcp and a if __name__ == "__main__": mcp.run() block.
  2. Install any extra dependencies into .venv.
  3. Register it in OpenCode (global config lives at ~/.config/opencode/opencode.json). V2 requires servers under mcp.servers. Use {env:NAME} for environment substitution — shell expansions like $HOME are not expanded in JSON:
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "filesystem": {
        "type": "local",
        "command": ["/home/sa/src/mymcp/.venv/bin/python", "-m", "servers.filesystem"],
        "cwd": "/home/sa/src/mymcp",
        "environment": {
          "FILESYSTEM_ROOTS": "{env:HOME}/src"
        }
      }
    }
  }
}

Alternatively, register from the shell (where $HOME does expand):

opencode mcp add filesystem --global \
  --env "FILESYSTEM_ROOTS=$HOME/src" \
  -- /home/sa/src/mymcp/.venv/bin/python -m servers.filesystem

Alternatively, register from the shell (where $HOME does expand) — using the absolute script path means the server also works from any workspace:

opencode mcp add websearch --global -- \
  /home/sa/src/mymcp/.venv/bin/python /home/sa/src/mymcp/servers/websearch.py

Then check the connection:

opencode mcp list

Each new server gets its own entry under mcp.servers with the same interpreter and -m servers.<name>.

About

My local MCP servers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages