haskell
An Awesome MCP Server Framework for Haskell
claude mcp add --transport stdio drshade-haskell-mcp-server docker run -i --entrypoint=/usr/local/bin/mcp-server haskell-mcp-server \ --env MCP_ENDPOINT="optional custom endpoint or host override" \ --env MCP_LOG_LEVEL="Info (optional) set logging level"
How to use
This MCP server provides a Haskell-based implementation of the Model Context Protocol (MCP) with support for multiple transports, including STDIO and Streamable HTTP. It exposes a type-safe API for prompts, resources, and tools, with automatic derivation options via Template Haskell or manual handler implementations. You can run the server in STDIO for local development or in a Docker container (as shown) to enable a production-like environment and integration with web-based clients. To interact with the server, you can use the generated MCP messages over JSON-RPC, and the HTTP transport exposes a dedicated endpoint to discover and submit MCP requests. If you use the Template Haskell derivations, you can automatically generate MCP schemas from your data types and customize descriptions if needed. For advanced usage, you can switch between automatic and manual handlers, and customize the server information (name, version, and instructions) to fit your deployment context.
How to install
Prerequisites:
- Haskell toolchain (GHC, Cabal or Stack)
- Either Cabal or Stack installed on your system
- Optional: Docker for containerized runs
Install options:
-
Using Cabal (recommended for pure Haskell projects):
- Ensure you have a working Haskell setup (GHCup recommended).
- Create or update your cabal project to include the dependency: build-depends: mcp-server
- Build and install: cabal update cabal build
-
Using Stack:
- Add mcp-server to your stack.yaml as a dependency or in your package.yaml/cabal file
- stack build
-
Running with Docker (as per the README example):
- Build the image (if you have a Dockerfile): docker build -t haskell-mcp-server .
- Run the server (STDIO entrypoint example): docker run -i --entrypoint="/usr/local/bin/mcp-server" haskell-mcp-server
Prerequisites recapped:
- A working Haskell toolchain (GHC, Cabal/Stack)
- knowledge of your chosen packaging method (Cabal/Stack/Docker)
- Optional Docker for containerized deployment
Additional notes
Notes and tips:
- The server supports multiple transports: STDIO and HTTP streaming. Use the built-in APIs or derive handlers for a faster setup.
- When using Template Haskell derivations, you can provide descriptions for constructors and fields via the provided WithDescription variants to improve MCP schema clarity.
- In Docker configurations, you can customize the entrypoint to point at the actual MCP server binary inside the image.
- If you enable the HTTP transport, you can configure CORS, endpoint path, and host/port via the HttpConfig structure as shown in the README.
- Common issues often relate to missing dependencies or incorrect serverInfo/handlers wiring. Ensure your serverInfo matches the actual capabilities of your handlers (prompts/resources/tools).
- Environment variables like MCP_LOG_LEVEL and MCP_ENDPOINT can help with debugging and endpoint routing when deploying in different environments.