mcp
Copyright(C) 2025 Matthias Pall Gissurarson
LicenseMIT
Maintainermpg@mpg.is
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageGHC2021

MCP.Server

Description

This module provides the core types and interface for MCP server implementations.

Synopsis

Server Interface

data ServerState Source #

Server state tracking initialization, capabilities, and subscriptions

Instances

Instances details
Show ServerState Source # 
Instance details

Defined in MCP.Server

data ServerConfig Source #

Configuration for running an MCP server

Instances

Instances details
Show ServerConfig Source # 
Instance details

Defined in MCP.Server

type MCPServerM = ReaderT ServerConfig (StateT ServerState (ExceptT Text IO)) Source #

The monad stack for MCP server operations

runMCPServer :: ServerConfig -> ServerState -> MCPServerM a -> IO (Either Text (a, ServerState)) Source #

Run an MCPServerM computation with the given config and initial state

initialServerState :: ServerCapabilities -> ServerState Source #

Create the initial server state with the given capabilities The server starts uninitialized and must receive an initialize request before it can handle other requests.

Utilities

sendResponse :: (MonadIO m, ToJSON a) => Handle -> RequestId -> a -> m () Source #

Send a JSON-RPC response

sendNotification :: (MonadIO m, ToJSON a) => Handle -> Text -> a -> m () Source #

Send a JSON-RPC notification

sendError :: MonadIO m => Handle -> RequestId -> JSONRPCErrorInfo -> m () Source #

Send a JSON-RPC error response