Logo vun MCP-Haskell

MCP-Haskell

Organisatioun
dpella

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

Editeurdpella
Repositorymcp
SproochHaskell
Forks
12
Stären
33
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzMPL-2.0
Linken
  • Tools mat KI-Workflows verbannen

    MCP-Haskell stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    33 Stären an 12 Forks aus dem verlinkte 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

MCP-Haskell MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal MCP-Haskell verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

MCP-Haskell als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu MCP-Haskell an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "dpella-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu MCP-Haskell. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu MCP-Haskell.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat MCP-Haskell?
MCP-Haskell
Jo. Ech hunn et gelies.
Dat hunn ech mat MCP-Haskell fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server MCP-Haskell benotzt?

MCP-Haskell ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech MCP-Haskell MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir MCP-Haskell mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat MCP-Haskell MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann MCP-Haskell verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech MCP-Haskell MCP mat TypingMind?

MCP-Haskell leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt MCP-Haskell MCP an TypingMind zur Verfügung?

MCP-Haskell stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir MCP-Haskell MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann MCP-Haskell eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇