Logo di MCP-Haskell

MCP-Haskell

Organizzazione
dpella

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

Autoredpella
Repositorymcp
LinguaHaskell
Fork
12
Stelle
33
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
LicenzaMPL-2.0
Link
  • Collega gli strumenti ai flussi di lavoro IA

    MCP-Haskell mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    33 stelle e 12 fork nel repository collegato.

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

Usa MCP MCP-Haskell con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso MCP-Haskell, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi MCP-Haskell come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di MCP-Haskell.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "dpella-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di MCP-Haskell, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di MCP-Haskell.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare MCP-Haskell per aiutarmi con questa attività?
MCP-Haskell
Certo. Ho letto.
Ecco cosa ho trovato con MCP-Haskell.

Domande frequenti

A cosa serve il server MCP MCP-Haskell?

MCP-Haskell è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare MCP-Haskell MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare MCP-Haskell con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP MCP-Haskell con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando MCP-Haskell, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego MCP-Haskell MCP a TypingMind?

MCP-Haskell funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre MCP-Haskell MCP in TypingMind?

MCP-Haskell mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare MCP-Haskell MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se MCP-Haskell richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇