Logo van MCP-Haskell

MCP-Haskell

Organisatie
dpella

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

Uitgeverdpella
Repositorymcp
TaalHaskell
Forks
12
Sterren
33
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMPL-2.0
Links
  • Koppel tools aan AI-workflows

    MCP-Haskell biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    33 sterren en 12 forks in de gekoppelde repository.

MCP — Model Context Protocol for Haskell

mcp on Hackage mcp-types on Hackage

A complete implementation of the Model 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

Overview

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.

Features

  • 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 via servant-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

Architecture

The implementation is organized into two packages:

mcp-types

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

mcp

Servant-based server implementation. Re-exports MCP.Protocol and MCP.Types for convenience.

  • MCP.Server: Core server infrastructure with MCPServerT monad transformer, ProcessHandlers record, ToolHandler framework, JWT-authenticated Servant API, server state management and request routing

For OAuth 2.0 authorization in MCP clients, see oauth2-server.

MCP Protocol Support

OperationDescriptionStatus
initializeStart session and negotiate capabilitiesSupported
pingHealth checkSupported
resources/listList available resourcesSupported
resources/templates/listList available resource templatesSupported
resources/readRead resource contentsSupported
resources/subscribeSubscribe to resource updatesSupported
resources/unsubscribeUnsubscribe from resource updatesSupported
prompts/listList available promptsSupported
prompts/getGet prompt with argumentsSupported
tools/listList available toolsSupported
tools/callExecute a toolSupported
completion/completeAuto-completion with contextSupported
logging/setLevelSet logging levelSupported
sampling/createMessageRequest LLM samplingSupported
roots/listList client root directoriesSupported
elicitation/createRequest user input via formsSupported

Install

For a server implementation, add mcp to your build-depends:

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

If you only need the protocol types (e.g. for a client), depend on mcp-types instead:

cabal
build-depends:
    base
  , aeson
  , mcp-types

This project targets GHC 9.12 (see cabal.project).

Quick Start

haskell
{-# 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!"]
  ]

Example Server

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

Run the example

bash
cabal run mcp-example

The server starts on http://localhost:8080/mcp and prints a JWT bearer token to stdout. Use it in the Authorization header for all requests:

bash
# 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}}}'

See mcp-server/example/SKILL.md for curl examples covering all 15 endpoints.

Project Structure

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

Development

bash
cabal build all
cabal test all

License

MPL-2.0 — see LICENSE in this repository.

References

Gebruik MCP-Haskell MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra MCP-Haskell is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg MCP-Haskell toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van MCP-Haskell.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "dpella-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van MCP-Haskell in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van MCP-Haskell in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je MCP-Haskell gebruiken om me hiermee te helpen?
MCP-Haskell
Zeker. Ik heb het gelezen.
Dit vond ik met MCP-Haskell.

Veelgestelde vragen

Waarvoor wordt de MCP-server MCP-Haskell gebruikt?

MCP-Haskell is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik MCP-Haskell MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je MCP-Haskell gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom MCP-Haskell MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als MCP-Haskell verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik MCP-Haskell MCP met TypingMind?

MCP-Haskell werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt MCP-Haskell MCP in TypingMind?

MCP-Haskell biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om MCP-Haskell MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als MCP-Haskell authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇