Documentation
¶
Overview ¶
Package server implements the MCP server that exposes ctx context files as resources, tools, and prompts over JSON-RPC 2.0 on stdin/stdout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an MCP server that exposes ctx context over JSON-RPC 2.0.
It reads JSON-RPC requests from stdin and writes responses to stdout, following the Model Context Protocol specification.
Thread-safety: outMu serialises all writes to out (main loop and poller goroutine). The main loop itself is single-threaded, so request dispatch and session mutations need no additional locking.
func NewServer ¶
NewServer creates a new MCP server for the given context directory.
Parameters:
- contextDir: path to the .context/ directory
- version: binary version string for the server info response
Returns:
- *Server: a configured MCP server ready to serve
Directories
¶
| Path | Synopsis |
|---|---|
|
Package catalog maps context files to MCP resource URIs and builds the immutable resource list returned by the server.
|
Package catalog maps context files to MCP resource URIs and builds the immutable resource list returned by the server. |
|
def
|
|
|
prompt
Package prompt defines MCP prompt definitions and entry builders.
|
Package prompt defines MCP prompt definitions and entry builders. |
|
tool
Package tool defines MCP tool definitions and shared property builders.
|
Package tool defines MCP tool definitions and shared property builders. |
|
Package dispatch routes MCP requests to domain-specific handlers based on method name.
|
Package dispatch routes MCP requests to domain-specific handlers based on method name. |
|
Package extract converts raw MCP tool arguments into typed Go values.
|
Package extract converts raw MCP tool arguments into typed Go values. |
|
Package io writes serialized JSON-RPC messages to an io.Writer with mutex-guarded concurrency.
|
Package io writes serialized JSON-RPC messages to an io.Writer with mutex-guarded concurrency. |
|
Package out builds JSON-RPC response structs for success, error, and tool result payloads.
|
Package out builds JSON-RPC response structs for success, error, and tool result payloads. |
|
Package parse unmarshals raw JSON bytes into MCP request structs, filtering out notifications.
|
Package parse unmarshals raw JSON bytes into MCP request structs, filtering out notifications. |
|
Package ping responds to MCP ping requests with an empty success result.
|
Package ping responds to MCP ping requests with an empty success result. |
|
Package poll watches subscribed resources for file changes and emits update notifications.
|
Package poll watches subscribed resources for file changes and emits update notifications. |
|
Package resource handles MCP resource requests including list, read, subscribe, and unsubscribe.
|
Package resource handles MCP resource requests including list, read, subscribe, and unsubscribe. |
|
route
|
|
|
fallback
Package fallback returns method-not-found errors for unrecognized MCP methods.
|
Package fallback returns method-not-found errors for unrecognized MCP methods. |
|
initialize
Package initialize handles the MCP initialize handshake and advertises server capabilities.
|
Package initialize handles the MCP initialize handshake and advertises server capabilities. |
|
prompt
Package prompt dispatches MCP prompt list and get requests to the appropriate builders.
|
Package prompt dispatches MCP prompt list and get requests to the appropriate builders. |
|
tool
Package tool dispatches MCP tool list and call requests to the appropriate handler functions.
|
Package tool dispatches MCP tool list and call requests to the appropriate handler functions. |
|
Package stat provides session statistics helpers for the MCP server.
|
Package stat provides session statistics helpers for the MCP server. |
Click to show internal directories.
Click to hide internal directories.