AshAi.Mcp.Server (ash_ai v0.2.2)

View Source

Implementation of the Model Context Protocol (MCP) RPC functionality.

This module handles HTTP requests and responses according to the MCP specification, supporting both synchronous and streaming communication patterns. It also handles the core JSON-RPC message processing for the protocol.

Summary

Functions

Get the MCP server name

Get the MCP server version

Handle HTTP DELETE request for session termination

Process an HTTP GET request to open an SSE stream

Process an HTTP POST request containing JSON-RPC messages

Create a standard JSON-RPC error response

Parse the JSON-RPC request

Process a single JSON-RPC message

Send an SSE event over the chunked connection

Functions

get_server_name(opts)

Get the MCP server name

get_server_version(opts)

Get the MCP server version

handle_delete(conn, session_id)

Handle HTTP DELETE request for session termination

handle_get(conn, session_id)

Process an HTTP GET request to open an SSE stream

handle_post(conn, body, session_id, opts \\ [])

Process an HTTP POST request containing JSON-RPC messages

json_rpc_error_response(id, code, message, data \\ nil)

Create a standard JSON-RPC error response

parse_json_rpc(request)

Parse the JSON-RPC request

process_message(message, session_id, opts)

Process a single JSON-RPC message

send_sse_event(conn, event, data, id \\ nil)

Send an SSE event over the chunked connection