muthuishere/mcp-server-bash-sdk

View on GitHub ↗

MCP server SDK/example implemented entirely in bash — build a Model Context Protocol server with no runtime dependency beyond a POSIX shell.

514 ★48 forksShellUpdated 1mo ago

What you need to know

A zero-overhead, pure-Bash implementation of the MCP server targeting the stateless 2026-07-28 revision: one script serves both stdio and Streamable HTTP, discovers tools dynamically by a `tool_*` naming convention, and validates output against the official published JSON schema.

Install

git clone https://github.com/muthuishere/mcp-server-bash-sdk && cd mcp-server-bash-sdk && chmod +x mcpserver_core.sh moviemcpserver.sh (needs Bash 3.2+, jq; socat for HTTP)

Usage

  • •Create a business-logic script that sources mcpserver_core.sh (and mcpserver_http.sh for HTTP) and defines `tool_*` functions.
  • •Each tool function takes arguments as JSON in $1; echo a result and `return 0`, or echo an error message and `return 1` (delivered as isError: true).
  • •Run `./yourserver.sh` for stdio or `./yourserver.sh --http` for Streamable HTTP at http://127.0.0.1:3000/mcp (MCP_HTTP_PORT / MCP_HTTP_BIND / MCP_HTTP_PATH / MCP_ALLOWED_ORIGINS).
  • •Every HTTP POST must carry MCP-Protocol-Version and Mcp-Method headers (plus Mcp-Name for tools/call) matching the request body.

Key features

  • ✓Implements MCP 2026-07-28 (stateless: server/discover, tools/list, tools/call) with per-request version negotiation.
  • ✓Both standard transports — stdio and Streamable HTTP — share one process_request so behavior cannot drift.
  • ✓Dynamic tool discovery by function name; tools JSON and server/discover config are plain JSON files.
  • ✓Output validated against the vendored official JSON schema; 31 unit + 19 HTTP tests verified on macOS, Debian/Ubuntu, and Alpine.

Best for

Shell-first environments (macOS, minimal containers) that want an MCP server with zero Python/Node overhead and no runtime beyond bash + jq.

Caveats

  • ⚠Targets MCP 2026-07-28 ONLY — clients on 2025-06-18 / 2025-11-25 are rejected (-32022) and need a shim.
  • ⚠No SSE response mode (no notifications/progress streaming, no subscriptions/listen); no resources, prompts, MRTR input requests, or the tasks extension.
  • ⚠No concurrency on stdio (~30 requests/second); the HTTP binding is a loopback local endpoint with no TLS or auth — without socat it serves one connection at a time.
Platforms: macOS · Linux · LocalClients: any MCP 2026-07-28 client

Reviewed 2026-08-18

Topics

ai-agentsbashmcpmodel-context-protocolsdk
Stars
514★
Forks
48
Language
Shell
License
MIT
Created
2025-05-29
Last push
2026-08-05