Skip to content

MCP servers

asksh can connect to external Model Context Protocol (MCP) servers over stdio or Streamable http (2025-03-26 protocol version) and expose their tools to the model.

Configuration

Add one or more [[mcp_servers]] blocks to ~/.config/asksh/config.toml:

[[mcp_servers]]
name = "greendale"
transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "."]
env = { NODE_ENV = "production" }
[[mcp_servers]]
name = "remote-tools"
transport = "http"
url = "https://mcp.greendale.edu/mcp"
headers = { Authorization = "Bearer ${MCP_TOKEN}" }
  • stdio servers: spawn as a subprocess with env merged over the current process environment, communicating via newline-delimited JSON-RPC 2.0. On shutdown, asksh closes stdin and waits up to 2 seconds before killing the process.
  • http servers: send JSON-RPC 2.0 POST requests to url (accepting application/json and text/event-stream SSE responses up to 16 MB) and forward any Mcp-Session-Id header returned by the server.

All configured servers connect concurrently at startup with a 10-second timeout. If one server fails to start or list tools, asksh prints a warning to stderr and continues with the remaining servers and built-in tools.

Tool naming and permissions

Every MCP tool is registered as mcp__<server>__<tool> and marked as non-read-only so asksh checks permissions.toml before calling it.

Use MCP(...) rules in permissions.toml to allow or deny whole servers or individual tools:

[permissions]
allow = ["MCP(greendale/*)"]
deny = ["MCP(greendale/drop_table)"]

See Permissions for rule precedence and [targets.<env>] overrides.