Haskell Type-Safe MCP MCP server

Enables developers to define and expose strongly-typed MCP prompts and tools using Haskell's type system with minimal boilerplate code.
Back to servers
Setup instructions
Provider
Tom Wells
Release date
May 21, 2025
Language
PHP
Stats
6 stars

This MCP server for Haskell allows you to define and execute structured prompts and tools using a type-safe approach. It enables communication between your Haskell code and MCP clients through a simple interface, making it easier to create interactive AI-powered applications.

Installation

Prerequisites

  • Haskell with GHC
  • Docker (optional, but recommended)

Building from Source

  1. Clone the repository and navigate to the project directory:
git clone [repository URL]
cd haskell-mcp
  1. Build the project using your preferred Haskell build tool (Stack or Cabal).

Using Docker (Recommended)

The project includes a Dockerfile for easy deployment:

  1. Build the Docker image:
docker build -t haskell-mcp:latest .

Usage

Creating Prompts and Tools

Define your prompts and tools as Haskell data types:

data Prompt = RobotStyle { feel :: String }

data Tool
    = GetAllGames
    | GetGameStatus  { gameid :: String }
    | MessagePlayers { message :: String }

Implementing Handlers

Implement functions to execute your prompts and tools:

executePrompt :: Prompt -> IO String
executePrompt (RobotStyle feel) = pure $ "Speak like a ROBOT with the following feel: " ++ feel

executeTool :: Tool -> IO String
executeTool GetAllGames                 = pure "List of all games: [Game1, Game2, Game3]"
executeTool (GetGameStatus gameid)      = pure $ "The status of game " ++ gameid ++ " is: RUNNING"
executeTool (MessagePlayers message)    = pure $ "Message sent to players: " ++ message

Running the MCP Server

Launch the MCP server with your defined prompts and tools:

main :: IO ()
main = runMcpServerStdIn
            YourModule.prompts YourModule.invokePrompt YourModule.executePrompt
            YourModule.tools YourModule.invokeTool YourModule.executeTool

Check the Examples/Planets directory for a complete working example.

Connecting with MCP Clients

Using Claude Desktop

  1. Ensure your Docker image is built
  2. Configure Claude Desktop to use your MCP server by adding this to your configuration:
{
    "mcpServers": {
        "haskell-mcp": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-i",
                "haskell-mcp:latest"
            ]
        }
    }
}
  1. Restart Claude Desktop, and you should now be able to use your Haskell MCP server.

Customizing Your Server

You can modify the examples provided in the repository to create your own set of prompts and tools. The MCP server handles all the communication protocol details, allowing you to focus on implementing the business logic for your prompts and tools.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "haskell-mcp" '{"command":"docker","args":["run","--rm","-i","haskell-mcp:latest"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "haskell-mcp": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-i",
                "haskell-mcp:latest"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "haskell-mcp": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-i",
                "haskell-mcp:latest"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later