agent-mcp
Enables web search through Brave when a BRAVE_API_KEY is configured; the websearch tool sends queries to Brave and returns search results.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-mcp search the repo for TODO comments and show me where they are"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agent-mcp
A cross-platform FastMCP server that exposes file, search, shell, and web tools with the same names and input fields as the built-in tools in OpenCode. It runs over Streamable HTTP (with a static bearer token) or stdio, on Linux, macOS, and Windows.
Use it to give an agent controlled access to another machine, or to replace a subset of local tools with a single authenticated MCP endpoint.
OpenCode / any MCP client
│ Authorization: Bearer <token>
▼
http://127.0.0.1:8765/mcp
│
├── read / write / edit / patch
├── glob / grep
├── shell
└── webfetch / websearchTool compatibility
Tool | Parameters (same names as OpenCode) | Behavior |
|
| Numbered lines, 2,000-line / 50 KiB pages, directory listings, images/audio/PDF as MCP media |
|
| Recursive glob, hidden filtering, newest first |
|
| Regex or literal content search; uses |
|
| Exact replacement; errors on ambiguous matches unless |
|
| Create or replace a file, creating parents |
|
|
|
|
| Host shell, millisecond timeout, process-tree kill, background log |
|
| Markdown reader with metadata, main-content extraction, |
|
| DuckDuckGo results with no API key; optional recency filter or news search |
Not mirrored: question, skill, subagent, and execute are client-side
tools. websearch uses DuckDuckGo's public endpoint and needs no provider key.
Related MCP server: DevSpace
Install
Requires Python 3.10+.
# from this checkout, in a project virtualenv
uv venv && uv pip install -e .
# or install the CLI in an isolated environment from the checkout
pipx install .
# uv tool install .
# or install directly from the public repository
pipx install "git+https://github.com/uukelele/agent-mcp.git"Run over HTTP
export AGENT_MCP_TOKEN="$(openssl rand -hex 32)"
agent-mcp \
--root /srv/project \
--host 127.0.0.1 \
--port 8765 \
--token "$AGENT_MCP_TOKEN"Endpoint: http://127.0.0.1:8765/mcp.
Every request must send
Authorization: Bearer <token>.Binding a non-loopback address without a token is refused unless you pass
--no-authexplicitly.--statelessremoves MCP session IDs (useful behind buffered proxies).--json-responsereturnsapplication/jsoninstead of request-scoped SSE.--allowed-host/--allowed-originextend FastMCP's Host/Origin guard when running behind a reverse proxy.
For a public deployment, terminate TLS in Caddy/nginx and forward to
127.0.0.1:8765; do not send bearer tokens over plain HTTP across a network.
Run with Docker
export AGENT_MCP_TOKEN="$(openssl rand -hex 32)"
mkdir -p workspace
docker compose up -dThe compose file publishes only 127.0.0.1:8765 and mounts ./workspace as
the sandbox root. The container runs as an unprivileged mcp user, but shell
still executes inside the container with that user's full access to the mounted
workspace. Add --allow-outside-root, --allow-private-web, or other flags to
the compose command only when you need them.
Run over stdio
agent-mcp --transport stdio --root /srv/projectOpenCode starts it for you:
{
"mcp": {
"servers": {
"tools": {
"type": "local",
"command": ["agent-mcp", "--transport", "stdio", "--root", "/srv/project"]
}
}
}
}Connect from OpenCode (HTTP)
Because this server uses a static header token and does not advertise OAuth,
set "oauth": false:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"tools": {
"type": "remote",
"url": "http://127.0.0.1:8765/mcp",
"oauth": false,
"headers": {
"Authorization": "Bearer {env:AGENT_MCP_TOKEN}"
}
}
}
}
}CLI equivalent:
opencode mcp add tools --url http://127.0.0.1:8765/mcp \
--header 'Authorization=Bearer {env:AGENT_MCP_TOKEN}'
# `mcp add` does not write oauth:false; add it to the generated entry.
opencode mcp listTool names are prefixed with the server name (for example tools_read,
tools_shell). Under OpenCode's default Code Mode they are grouped under the
server namespace. Set "codemode": false on the server if you want them exposed
directly in the native tool list.
Authentication
--token/AGENT_MCP_TOKEN/MCP_AUTH_TOKENsets the only accepted bearer token. Tokens shorter than 16 characters are rejected.The token is compared with
secrets.compare_digest.--no-authis required to run HTTP without authentication. It is only sensible on loopback.--print-configshows the resolved settings with the token redacted.
Cross-platform behavior
Shell: on Linux/macOS the default is
$SHELL -lc(falling back tobash/sh); on Windows it is PowerShell (pwsh/powershell) with-NoProfile -NonInteractive -Command, falling back tocmd.exe /d /s /c. Override with--shellorAGENT_MCP_SHELL. Background commands write their log to<root>/.agent-mcp/shell/, soreadcan access it inside the sandbox; add that directory to.gitignore.Process trees: timeouts kill the whole tree with
killpgon POSIX andtaskkill /Ton Windows.Encoding: UTF-8, UTF-8/UTF-16/UTF-32 BOMs, BOM-less UTF-16, and the platform ANSI code page are detected. Edits round-trip the original encoding and BOM byte-for-byte.
Newlines: CRLF, LF, and CR are preserved when editing or patching.
Paths: relative paths resolve against
--root; absolute paths are checked withcommonpath, including Windows drive letters. Glob/grep display workspace-relative POSIX paths for consistent agent output.Atomic writes: temp file in the target directory,
fsync, thenos.replace; existing permissions are preserved.
Patch format
*** Begin Patch
*** Add File: hello.txt
+hello
*** Update File: hello.txt
@@
hello
-world
+there
*** Update File: old.txt
*** Move to: new.txt
@@
-a
+b
*** Delete File: gone.txt
*** End PatchEvery operation is parsed and every hunk is matched before anything is written. A missing context line aborts the whole patch. New files are written as UTF-8 with LF; updates keep the file's existing encoding and newline style.
Security model
File access is confined to
--rootunless--allow-outside-rootis set. Symlink targets are resolved before the containment check.shellis not sandboxed. It runs as the server user with that user's full privileges. Run the server as a dedicated, unprivileged account and restrict network access.webfetchchecks every redirect hop and pins the connection to the checked DNS address, so rebinding cannot swap in a private host. Loopback, private, link-local, and reserved addresses are blocked by default, and cloud metadata addresses stay blocked even with--allow-private-web.websearchonly calls DuckDuckGo throughddgs; it needs no API key.shellinherits the server environment, including any provider API keys stored there. Run the service under a dedicated account and keep unrelated secrets out of its environment.Keep the token in an environment variable, not in a world-readable config.
Limitations
readreturns PDFs as embedded resources rather than extracting text.grepuses Python'sreengine in the fallback path: lookaround works, but\p{...}and some PCRE syntax do not. With ripgrep, matching uses ripgrep's Rust regex syntax (no lookaround unless--pcre2is added) but is faster. Ripgrep detects UTF-16 with a BOM; BOM-less UTF-16 is covered by the Python fallback. Anchor patterns or narrow withincludefor predictable results.globreturns files, not directories.Background shell commands return immediately; there is no completion notification. Poll the returned log path with
read.webfetchdoes not run JavaScript. JavaScript-only pages, bot checks, and paywalls may return an error or a link-preview summary; use another source.webfetchprefers a site's Markdown version,.mdtwin, and/llms.txtwhen present. HTML extraction is heuristic, so some unusual layouts may lose content. Site-specific readers cover X/Twitter, YouTube, Reddit, Stack Exchange, TikTok, and link-preview-only social sites.webfetchreturns PDFs and images as MCP file/image content;format="text"andformat="html"use a simpler raw fetch without main-content extraction.websearchdepends on DuckDuckGo's public endpoint; rate limits or changes on their side can make a search fail. Re-run or rephrase the query.The server does not implement OpenCode's permission prompts, snapshots, or
patch-for-GPT-only policy. Your MCP client decides when to call a tool.
Development
uv venv
uv pip install -e ".[dev]" # or: uv pip install -e . pytest httpx
.venv/bin/pytest
.venv/bin/agent-mcp --print-configLicense
MIT. The web reader, site-specific readers, and search result formatting are adapted from the author's Obsidian project.
Available Tools
9 toolseditEditADestructive
Replace exact text in a file. oldString must match exactly once unless replaceAll=true. The file's encoding and newline style are preserved. Returns a unified diff.
Inputs: path (required), newString (required), oldString (required), replaceAll. Returns: result
globGlobARead-only
Find files by glob pattern such as '**/*.ts'. Hidden files are skipped unless hidden=true. Results are newest first.
Inputs: pattern (required), path, limit, hidden. Returns: result
grepGrepARead-only
Search file contents with a regular expression (or literal text). Narrow with path and include, e.g. include='*.ts'. Returns path:line: text.
Inputs: pattern (required), path, limit, include, +2 more. Returns: result
patchPatchADestructive
Apply an OpenCode/Codex patch envelope with *** Begin Patch, *** Add File, *** Update File, *** Move to, and *** Delete File. All hunks are validated before any file is written.
Inputs: patchText (required). Returns: result
readReadARead-only
Read a file or list a directory. Text is returned with line numbers. Use offset (1-based) and limit to page through large files.
Inputs: path (required), limit, offset.
shellShellBDestructive
Run a command in the host shell. timeout is in milliseconds (0 disables it). Set background=true to start a long-running process; the result contains its PID and log path.
Inputs: command (required), timeout, workdir, background. Returns: result
webfetchWebfetchBRead-only
Fetch an HTTP or HTTPS URL as markdown (default), text, or raw HTML. Private and loopback addresses are blocked unless the operator allows them.
Inputs: url (required), format, timeout. Returns: result
websearchWebsearchBRead-only
Search the web. Requires BRAVE_API_KEY or TAVILY_API_KEY in the server environment; returns a clear error when neither is configured.
Inputs: query (required). Returns: result
writeWriteADestructive
Create or completely replace a text file. Missing parent directories are created. Prefer edit for small changes to existing files.
Inputs: path (required), content (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Content search (grep) vs filename search (glob) vs read are clearly separated, as are webfetch and websearch. The main overlap is edit vs patch, both of which modify existing files, but descriptions steer usage ('Prefer edit for small changes', patch is for multi-file envelopes). Minor write vs edit overlap is also softened by explicit guidance.
All nine tools follow one convention: single lowercase words, no separators, no mixed styles (grep, edit, write, patch, shell, webfetch, read, glob, websearch). The pattern is predictable and readable even though it is not verb_noun.
Nine tools is a well-scoped surface for an agent file/shell/web toolkit, with each tool earning its place across read, search, mutate, and network operations. No thin filler tools and no bloat.
Core lifecycle is covered: read/list, glob, grep, write/create, edit, patch (including add/move/delete files), shell, plus fetch and search. Gaps are minor, e.g. no direct file delete outside a patch envelope and no way to inspect or kill processes started with background=true.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Related MCP Servers
- AlicenseCqualityDmaintenanceA security-first MCP server that provides LLMs with structured tools for filesystem, process, search, build/test/lint, IDE integration, and more.402PolyForm Noncommercial 1.0.0
- AlicenseNot gradedqualityAmaintenanceThis self-hosted MCP server connects an MCP client such as ChatGPT to approved local project folders, enabling file reading and editing, code search, shell command execution, and Git worktree workflows without uploading code to a third party. It also supports mounting external stdio or Streamable HTTP MCP servers as dynamic capabilities.597 npmMIT
- AlicenseNot gradedqualityBmaintenanceA local-first MCP server that enables AI-assisted coding through workspace-scoped tools for file reading/editing, command execution, jobs, Git, LSP, media, browser, and desktop workflows. It enforces OAuth, workspace ACL, trust policies, and file/secret guards so owners can safely grant inspect, edit, or trusted capabilities.346 npmMIT
- AlicenseAqualityCmaintenanceA safety-first local MCP server that enables bounded file reading, text search, line-range editing with optimistic locking, and read-only git diff operations within a single code workspace.6MIT