MCP-Haskell

by tritlo

Not rated
GitHub

About

A complete Model Context Protocol (MCP) implementation for Haskell, supporting both StdIO and HTTP transport.

Details

Author
tritlo
Categories
Developer Tools, API

Setup

Install MCP-Haskell in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/tritlo/mcp

Follow the installation instructions in the repository README, then restart your MCP client.

MCP — Model Context Protocol for Haskell

A complete implementation of theModel Context Protocol (MCP)for Haskell, split into two packages:

- mcp-types— Pure protocol types with minimal dependencies (aeson, base, containers, text)
- mcp— Servant-based HTTP server with JWT authentication

This repository provides a type-safe implementation of the Model Context Protocol in Haskell. MCP is an open protocol that standardizes how applications provide context to Large Language Models (LLMs), enabling AI models to securely connect to data sources and tools.

- Latest Protocol Support: Implements MCP protocol version 2025-06-18
- Complete MCP Protocol Implementation: All MCP message types, requests, responses, and notifications
- Type-Safe Design: Full Haskell type system integration with automatic JSON serialization via Aeson
- HTTP Transport: Servant-based HTTP server with streaming SSE responses
- JWT Authentication: Secure authentication viaservant-auth-server
- Extensible Server Interface: Configurable handler framework for implementing custom MCP servers
- Tool Framework: Helper functions for defining tools with input validation and structured results

The implementation is organized into two packages:

Core protocol types with minimal dependencies — suitable for building clients or alternative server implementations.

- MCP.Types: Core MCP data types (Content, Resource, Tool, Prompt, Capability, etc.)
- MCP.Protocol: JSON-RPC 2.0 message wrappers, all client/server request/response types, notification types
- MCP.Aeson: Custom Aeson parsing options

Servant-based server implementation. Re-exportsMCP.ProtocolandMCP.Typesfor convenience.

- MCP.Server: Core server infrastructure withMCPServerTmonad transformer,ProcessHandlersrecord,ToolHandlerframework, JWT-authenticated Servant API, server state management and request routing

For OAuth 2.0 authorization in MCP clients, seeoauth2-server.

For a server implementation, addmcpto yourbuild-depends:

build-depends: base , servant , servant-server , servant-auth-server , aeson , mcp

If you only need the protocol types (e.g. for a client), depend onmcp-typesinstead:

This project targets GHC 9.12 (seecabal.project).

{-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} import Control.Concurrent.MVar (newMVar) import MCP.Server -- Define your handler state and user types type instance MCPHandlerState = () type instance MCPHandlerUser = MyUser -- Create server state with capabilities mkServerState :: IO (MVar MCPServerState) mkServerState = do let impl = Implementation "my-server" "1.0.0" Nothing caps = ServerCapabilities { logging = Nothing , prompts = Nothing , resources = Nothing , tools = Just (ToolsCapability { listChanged = Just True }) , completions = Nothing , experimental = Nothing } handlers = withToolHandlers myTools defaultProcessHandlers newMVar $ initMCPServerState () Nothing Nothing caps impl Nothing handlers -- Define tools using the ToolHandler framework myTools :: [ToolHandler] myTools = [ toolHandler "greet" (Just "Say hello") greetSchema $ \_args -> return $ ProcessSuccess $ toolTextResult ["Hello!"] ]

A fully documented example server lives inmcp-server/example/. It demonstrates every major feature: tools, resources, resource templates, prompts, completions, logging, lifecycle hooks, and JWT authentication.

The server starts onhttp://localhost:8080/mcpand prints a JWT bearer token to stdout. Use it in theAuthorizationheader for all requests:

# Initialize the session (replace $TOKEN with the printed token) curl -s -X POST http://localhost:8080/mcp \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $TOKEN" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}' # Send initialized notification curl -s -X POST http://localhost:8080/mcp \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $TOKEN" \ -d '{"jsonrpc":"2.0","method":"notifications/initialized","params":null}' # List available tools curl -s -X POST http://localhost:8080/mcp \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $TOKEN" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' # Call the add tool curl -s -X POST http://localhost:8080/mcp \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $TOKEN" \ -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"add","arguments":{"a":17,"b":25}}}'

Seemcp-server/example/SKILL.mdfor curl examples covering all 15 endpoints.

mcp-types/ # Core protocol types package ├── src/MCP/ │ ├── Aeson.hs # Custom Aeson parsing options │ ├── Protocol.hs # JSON-RPC protocol messages │ └── Types.hs # Core MCP data types └── mcp-types.cabal mcp-server/ # Server implementation package ├── src/MCP/ │ ├── Server.hs # Re-exports Common, HTTP, and Stdio │ └── Server/ │ ├── Common.hs # Types, state, request routing, tool helpers │ ├── HTTP.hs # Servant-based HTTP transport with JWT auth │ └── Stdio.hs # Stdio transport ├── test/ │ ├── Main.hs # Test entry point │ └── MCP/ │ ├── Integration.hs # HTTP integration tests (hspec-wai) │ ├── StdioIntegration.hs # Stdio integration tests │ ├── TestServer.hs # Test server configuration │ └── TestUtils.hs # Test utilities and request builders ├── example/ │ ├── Main.hs # Example server (tools, resources, prompts, etc.) │ ├── mcp-example.cabal # Standalone cabal project │ ├── mcp-config.json # Claude Desktop MCP configuration template │ └── SKILL.md # Build, run, and test instructions └── mcp.cabal

MPL-2.0 — seeLICENSEin this repository.

- Model Context Protocol Specification
-
MCP TypeScript SDK
-
Official MCP Documentation

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.

The MCP server for Bitrix24 provides AI assistants with structured access to the Bitrix24 API. It delivers up-to-date method descriptions, parameters, and valid values, allowing assistants to work with precise data instead of guesswork. This reduces code errors and accelerates Bitrix24 integration development.

Tool platform by IBM to build, test and deploy tools for any data source

One remote MCP server for 500+ production APIs — Stripe, HubSpot, Postgres, Gmail, and more. OAuth and API key auth, credential management, and a CLI.

An MCP server for interacting with the Postman API, requiring an API key.

Arbitrary code execution and tool-use platform for LLMs by Riza

A command-line tool for interacting with Shopify's Admin GraphQL API, Functions, and Polaris Web Components.

Single tool to control all 100+ API integrations, and UI components

Agent-native developer Q&A API with MCP + A2A endpoints for citations, job pickup, and answer submission.

An MCP server for ABP.IO that enables AI models to interact with your ABP applications and framework.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.