effectful-mcp: Model Context Protocol servers in Effectful

[ ai, bsd3, control, library, network ] [ Propose Tags ] [ Report a vulnerability ]

A server of the Model Context Protocol (MCP) for Effectful: declare tools as Eff actions, and serve them over stdio, concurrently, with cancellation. It speaks revision 2026-07-28 of the protocol and, to the clients that only know them, the earlier ones.


[Skip to Readme]

Modules

  • Effectful
    • MCP
      • Effectful.MCP.JsonRpc
      • Effectful.MCP.Server
      • Effectful.MCP.Tool

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.3 && <2.4), base (>=4.19 && <4.22), base64-bytestring (>=1.2 && <1.3), bytestring (>=0.12 && <0.13), containers (>=0.6.7 && <0.8), effectful (>=2.7 && <2.8), effectful-core (>=2.7.1 && <2.8), scientific (>=0.3 && <0.4), streamly-core (>=0.3.3 && <0.4), text (>=2.1 && <2.2) [details]
Tested with ghc ==9.8.4 || ==9.10.3 || ==9.12.4
License BSD-3-Clause
Author Xavier Dectot
Maintainer Xavier Dectot <xavier@wheredoibegin.fr>
Uploaded by GdeVolpiano at 2026-11-28T10:21:52Z
Category AI, Network, Control
Home page https://github.com/GuillaumedeVolpiano/effectful-mcp
Source repo head: git clone https://github.com/GuillaumedeVolpiano/effectful-mcp.git
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-11-28 [all 1 reports]

Readme for effectful-mcp-0.1.0.0

[back to package description]

effectful-mcp

A server of the Model Context Protocol (MCP), revision 2026-07-28 and the earlier ones, for Effectful: declare tools as Eff actions, and serve them over stdio.

{-# LANGUAGE OverloadedStrings #-}

import Data.Aeson (FromJSON (parseJSON), object, withObject, (.:), (.=))
import Data.Text (Text)
import Effectful (runEff)
import Effectful.Concurrent (runConcurrent)
import Effectful.MCP.Server (implementation, serveStdio, serverConfig)
import Effectful.MCP.Tool (textResult, tool, withArguments)

newtype Greeting = Greeting Text

instance FromJSON Greeting where
  parseJSON = withObject "Greeting" $ \fields -> Greeting <$> fields .: "name"

main :: IO ()
main =
  runEff . runConcurrent . serveStdio $
    serverConfig
      (implementation "greeter" "0.1.0")
      [ tool "greet" "Greet someone" schema $
          withArguments (\(Greeting name) -> pure (textResult ("Hello, " <> name)))
      ]
  where
    schema =
      object
        [ "type" .= ("object" :: Text)
        , "properties" .= object ["name" .= object ["type" .= ("string" :: Text)]]
        , "required" .= ["name" :: Text]
        ]

What it does

  • Revision 2026-07-28: every request carries its protocol version and the capabilities of the client in _meta, and is served on its own. Clients that speak both eras, such as current versions of Claude Code, probe with server/discover first and use this revision.
  • The earlier revisions (2025-11-25 and before): initialize selects them for the connection, and tools/list, tools/call and ping are then answered as they describe. Clients that only know them, such as the Claude desktop application at the time of writing, are served this way.
  • Both at once on one connection, as revision 2026-07-28 allows: what a request carries tells which it is.
  • server/discover, tools/list (in a fixed order, with cache hints) and tools/call.
  • Tool failures, including arguments that do not decode, come back as results with isError, which the model can act on; protocol errors use the JSON-RPC codes of the specification.
  • Requests are served concurrently; notifications/cancelled stops one. When the input ends, running requests get a grace period to finish.
  • Not yet: resources, prompts, subscriptions, multi round-trip requests, progress, the Streamable HTTP transport.

Requests run in threads of their own, forked as Effectful forks them: a tool that changes a local State changes its own copy. Use shared effects for state that must outlive a call.

Tested with GHC 9.8.4, 9.10.3 and 9.12.4, effectful 2.7.1, streamly-core 0.3.3.

License

BSD-3-Clause. See LICENSE.