pw.xpacks.llm.mcp_server

class McpConfig(name='pathway-mcp-server', transport='streamable-http', host=None, port=None)

[source]

A configuration class for the McpServer.

class McpServable

[source]

Abstract base class for objects that can be registered with an McpServer.

Implement this class to define a component compatible with PathwayMcp.

class McpServer(config)

[source]

A server implementing MCP (Model Context Protocol).

It is encouraged to use the py:class:~pathway.xpacks.llm.mcp_server.PathwayMcp class for easier configuration.

classmethod get(config)

sourceReturns an instance of the MCP server with the given configuration.

tool(name, *, request_handler, schema, delete_completed_queries=False, cache_strategy=None, title=None, output_schema=_no_default_value_marker, annotations=None, meta=None, autocommit_duration_ms=50)

sourceRegisters a callable as an MCP tool.

  • Parameters
    • name (str) – Tool name exposed by the MCP server.
    • request_handler (Callable) – Callable to process queries.
    • schema (type[Schema]) – Query schema, used to generate tool input schema.
    • delete_completed_queries (bool) – Delete completed queries, default False.
    • cache_strategy (CacheStrategy | None) – Optional caching strategy.
    • title (str | None) – Optional tool title for display purposes, name is used if missing.
    • output_schema (dict[str, Any] | None | _Undefined) – Optional output schema.
    • annotations (dict[str, Any] | None) – Optional specialized metadata like readOnlyHint, idempotentHint, …
    • meta (dict[str, Any] | None) – Optional tool metadata.
    • autocommit_duration_ms (int | None) – Maximum time between two commits in milliseconds.

class PathwayMcp(transport='streamable-http', host=None, port=None, name='pathway-mcp-server', serve=<factory>)

[source]

A configuration class that simplifies the definition of MCP servers with compatible servables.

  • Parameters
    • transport (Literal['streamable-http', 'stdio']) – The transport protocol used by the server. The ‘stdio’ transport is unstable and experimental. It may change or be removed in future releases. Defaults to “streamable-http”.
    • None (host The hostname or IP address to bind the server to. If) –
    • binding. (uses default) –
    • port (int | None) – The port number to bind the server to. If None, uses default port.
    • name (str) – The name of the MCP server instance. Defaults to “pathway-mcp-server”.
    • serve (list[McpServable]) – A list of McpServable objects to register with the MCP server.