Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

hs-mcp

MCP.Pizza Chef: buecking

hs-mcp is a Haskell client implementation of the Model Context Protocol (MCP), enabling Haskell applications to integrate with MCP-compatible AI models and services. It supports full MCP protocol features including JSON-RPC messaging, StdIO transport for local communication, and management of resources, tools, and prompts. Designed for developers building AI-enhanced workflows in Haskell, it offers a comprehensive test suite and easy installation via nix and cabal.

Use This MCP client To

Integrate Haskell apps with MCP-compatible AI models like Claude Manage AI tools and resources within Haskell workflows Enable JSON-RPC communication for AI context sharing Use StdIO transport for local AI process interaction Develop AI copilots and agents in Haskell environments Test MCP protocol implementations with built-in test suite

README

MCP-Haskell (hs-mcp)

A Haskell implementation of the Model Context Protocol (MCP).

Overview

MCP-Haskell (hs-mcp) provides a Haskell implementation of the Model Context Protocol, allowing Haskell applications to expose tools, resources, and prompts to MCP-compatible clients like Claude.

Key features:

  • Full implementation of MCP protocol
  • StdIO transport for local process communication
  • JSON-RPC messaging
  • Support for resources, tools, and prompts
  • Comprehensive test suite

Installation

# Clone the repository
git clone github.com:buecking/hs-mcp.git
cd hs-mcp

# direnv
# echo 'use flake' > .envrc
direnv allow

# nix
nix develop

# Build the project
cabal build

Usage

Creating a simple server

import Network.MCP.Server
import Network.MCP.Types
import Network.MCP.Server.StdIO

main :: IO ()
main = do
  -- Create server
  let serverInfo = Implementation "my-server" "1.0.0"
      serverCapabilities = ServerCapabilities
        { resourcesCapability = Just $ ResourcesCapability True
        , toolsCapability = Just $ ToolsCapability True
        , promptsCapability = Nothing
        }
  
  server <- createServer serverInfo serverCapabilities
  
  -- Register resources (optional)
  let resource = Resource 
        { resourceUri = "my://resource"
        , resourceName = "My Resource"
        , resourceDescription = Just "Description"
        , resourceMimeType = Just "text/plain"
        , resourceTemplate = Nothing
        }
  
  registerResources server [resource]
  
  -- Register resource read handler
  registerResourceReadHandler server $ \request -> do
    -- Implement resource reading logic
    ...

  -- Register tools (optional)
  let tool = Tool 
        { toolName = "my-tool"
        , toolDescription = Just "My tool"
        , toolInputSchema = "{...}" -- JSON schema
        }
  
  registerTools server [tool]
  
  -- Register tool call handler
  registerToolCallHandler server $ \request -> do
    -- Implement tool execution logic
    ...
  
  -- Start the server with StdIO transport
  runServerWithSTDIO server

Example Server

The project includes an example echo server that demonstrates the MCP functionality:

# Build and run the example server
cabal run mcp-echo-server

You can test it with the MCP Inspector or Claude Desktop.

Testing

Run the test suite:

cabal test

Protocol Compatibility

This implementation follows the Model Context Protocol specification and is compatible with:

  • Claude Desktop
  • MCP Inspector
  • Other MCP clients following the specification

Project Structure

  • src/Network/MCP/Types.hs - Core MCP types
  • src/Network/MCP/Transport/ - Transport implementations
  • src/Network/MCP/Server/ - Server implementation
  • Examples/ - Example implementations
  • Test/ - Test suite

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.

hs-mcp FAQ

How do I install hs-mcp?
Clone the GitHub repo, use nix or cabal to build, and enable direnv for environment setup.
What transport protocols does hs-mcp support?
It supports StdIO transport for local process communication.
Can hs-mcp handle tools and resources?
Yes, it supports managing resources, tools, and prompts as per MCP specifications.
Is there a test suite available?
Yes, hs-mcp includes a comprehensive test suite to validate MCP implementations.
Which LLM providers can I use with hs-mcp?
hs-mcp is provider-agnostic and works with models like OpenAI, Claude, and Gemini.
How does hs-mcp communicate with AI models?
It uses JSON-RPC messaging over StdIO or other transports to exchange structured context.
Can I extend hs-mcp for custom MCP features?
Yes, its modular design allows extension for custom tools and resource handling.
Is hs-mcp suitable for production use?
While it is a work in progress, it is designed for robust Haskell MCP client implementations.