polytropos-mcp: Model Context Protocol (MCP) server integration for polytropos

[ ai, library, web ] [ Propose Tags ] [ Report a vulnerability ]

Model Context Protocol (MCP) tool integration and JSON-RPC dispatch for polytropos open records and variants.

Synthesizes MCP tool definitions and OpenAPI input schemas directly from polytropos open records, and dispatches tool execution requests to open variant handlers with O(1) jump table elimination. Includes a stdio transport runner for AI coding agents and language models.

Start at the front door module Polytropos.MCP for protocol types, tool builders, and worked examples.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.2
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <2.3), base (>=4.14 && <5), bytestring (>=0.10 && <0.13), openapi3 (>=3.2 && <3.3), polytropos-aeson (>=0.1 && <0.2), polytropos-core (>=0.1 && <0.2), polytropos-openapi3 (>=0.1 && <0.2), polytropos-plugin (>=0.1 && <0.2), text (>=1.2 && <2.2) [details]
License (EUPL-1.2 OR Apache-2.0)
Author Nadia Yvette Chambers
Maintainer nadia.yvette.chambers@ik.me
Uploaded by nyc at 2026-10-21T21:34:36Z
Category Web, AI
Home page https://github.com/NadiaYvette/polytropos
Bug tracker https://github.com/NadiaYvette/polytropos/issues
Source repo head: git clone https://github.com/NadiaYvette/polytropos(packages/polytropos-mcp)
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-10-21 [all 1 reports]

Readme for polytropos-mcp-0.1.0.2

[back to package description]

polytropos-mcp

Model Context Protocol (MCP) JSON-RPC 2.0 server implementation for polytropos open records and variants.

Overview

polytropos-mcp implements the Anthropic Model Context Protocol specification for agentic tooling. It leverages open product rows for compile-time OpenAPI 3.0 tool schema generation and open variant sum rows for \(O(1)\) jump table tool call dispatch.

Features

  • recordToTool: Derives compliant OpenAPI 3.0 input schemas directly from open product row types (Proxy (r :: Row)).
  • toolCallToVariant & dispatchToolCall: Parses JSON tool call arguments into open variants and executes handlers via eliminateUniform.
  • runStdioServer: Complete stdio server loop handling lifecycle handshakes (initialize, tools/list, tools/call).

Quick Example

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fplugin=Polytropos.Plugin #-}

import Data.Proxy (Proxy (..))
import Data.Text (Text)
import Polytropos
import Polytropos.MCP

-- Define tool parameter rows
type SearchArgs = '["query" ':= Text, "limit" ':= Int]
type EchoArgs   = '["message" ':= Text]

-- Tool registry as an open variant
type MyTools = Variant
  '[ "search" ':= SearchArgs
   , "echo"   ':= EchoArgs
   ]

-- Export tool specifications with OpenAPI schemas
tools :: [McpTool]
tools =
  [ recordToTool @"search" "Search indexed documents" (Proxy @SearchArgs)
  , recordToTool @"echo"   "Echo back a message"      (Proxy @EchoArgs)
  ]

-- Dispatch calls in O(1) jump table
handleCall :: MyTools -> IO [McpContent]
handleCall = eliminateUniform REC
  { search = \args -> pure [TextContent ("Found hits for: " <> args.query)]
  , echo   = \args -> pure [TextContent ("Echo: " <> args.message)]
  }

License

Dual-licensed under EUPL-1.2 OR Apache-2.0.