mcp

package
v0.9.8-dev.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp assembles the Kivgraph MCP server: the tool surface, the instructions returned at handshake, and the transports it is served over.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStream = errors.New("mcp: transport has no stream")

ErrNoStream is returned by a StreamTransport with nothing to talk over.

Functions

func NewServer

func NewServer() *sdkmcp.Server

NewServer creates the Kivgraph MCP server with no graph source.

func NewServerWithIndexer

func NewServerWithIndexer(indexer indexing.ProjectIndexer) *sdkmcp.Server

NewServerWithIndexer creates a server that also exposes the explicit permission-gated index_project mutation.

func NewServerWithMetrics

func NewServerWithMetrics(registry *metrics.Registry) *sdkmcp.Server

NewServerWithMetrics creates the server without a graph source and records query metrics in registry.

func NewServerWithMetricsAndSnapshotStore

func NewServerWithMetricsAndSnapshotStore(registry *metrics.Registry, snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server

NewServerWithMetricsAndSnapshotStore creates the snapshot-backed server and records query metrics in registry.

func NewServerWithMetricsAndSnapshotStoreAndIndexer

func NewServerWithMetricsAndSnapshotStoreAndIndexer(
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
) *sdkmcp.Server

NewServerWithMetricsAndSnapshotStoreAndIndexer combines query metrics with the configured project indexer.

func NewServerWithMetricsAndSnapshotStoreAndIndexerOptions added in v0.9.2

func NewServerWithMetricsAndSnapshotStoreAndIndexerOptions(
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
	options ServerOptions,
) *sdkmcp.Server

NewServerWithMetricsAndSnapshotStoreAndIndexerOptions is the configured server with the surface options applied. ServerOptions{} builds exactly what NewServerWithMetricsAndSnapshotStoreAndIndexer builds.

func NewServerWithObserver

func NewServerWithObserver(observer tools.Observer) *sdkmcp.Server

NewServerWithObserver creates the server without a graph source and observes tool-handler latency.

func NewServerWithObserverAndMetrics

func NewServerWithObserverAndMetrics(observer tools.Observer, registry *metrics.Registry) *sdkmcp.Server

NewServerWithObserverAndMetrics creates the server without a graph source, observing latency and recording query metrics in registry.

func NewServerWithObserverAndMetricsAndSnapshotStore

func NewServerWithObserverAndMetricsAndSnapshotStore(
	observer tools.Observer,
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
) *sdkmcp.Server

NewServerWithObserverAndMetricsAndSnapshotStore combines the legacy latency observer with the process-local metrics registry.

func NewServerWithObserverAndSnapshotStore

func NewServerWithObserverAndSnapshotStore(observer tools.Observer, snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server

NewServerWithObserverAndSnapshotStore creates the snapshot-backed server and observes tool-handler latency.

func NewServerWithSnapshotStore

func NewServerWithSnapshotStore(snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server

NewServerWithSnapshotStore creates the server backed by the published immutable HotSnapshot.

func NewServerWithSnapshotStoreAndIndexer

func NewServerWithSnapshotStoreAndIndexer(
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
) *sdkmcp.Server

NewServerWithSnapshotStoreAndIndexer creates the configured server backed by the published snapshot and an authorized project indexer.

func Run

func Run(ctx context.Context) error

Run serves one MCP session over the process stdin/stdout transport with a process-local metrics registry available to graph_status.

func RunWithMetrics

func RunWithMetrics(ctx context.Context, registry *metrics.Registry) error

RunWithMetrics serves one MCP session with the caller-owned metrics registry.

func RunWithMetricsAndSnapshotStore

func RunWithMetricsAndSnapshotStore(
	ctx context.Context,
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
) error

RunWithMetricsAndSnapshotStore serves one MCP session with caller-owned metrics and the immutable graph source.

func RunWithMetricsAndSnapshotStoreAndIndexer

func RunWithMetricsAndSnapshotStoreAndIndexer(
	ctx context.Context,
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
) error

RunWithMetricsAndSnapshotStoreAndIndexer serves one MCP session with caller-owned metrics, the immutable graph source, and an authorized project indexer.

func RunWithMetricsAndSnapshotStoreAndIndexerOptions added in v0.9.2

func RunWithMetricsAndSnapshotStoreAndIndexerOptions(
	ctx context.Context,
	registry *metrics.Registry,
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
	options ServerOptions,
) error

RunWithMetricsAndSnapshotStoreAndIndexerOptions is the same session with the surface options applied. ServerOptions{} serves exactly what RunWithMetricsAndSnapshotStoreAndIndexer serves.

func RunWithSnapshotStore

func RunWithSnapshotStore(ctx context.Context, snapshotStore *hotsnapshot.SnapshotStore) error

RunWithSnapshotStore serves one MCP session using snapshotStore as the immutable graph source for query tools and a fresh metrics registry.

func RunWithSnapshotStoreAndIndexer

func RunWithSnapshotStoreAndIndexer(
	ctx context.Context,
	snapshotStore *hotsnapshot.SnapshotStore,
	indexer indexing.ProjectIndexer,
) error

RunWithSnapshotStoreAndIndexer serves the configured MCP surface, including the permission-gated index_project tool.

Types

type ServerOptions added in v0.9.2

type ServerOptions struct {
	// ExposeUnavailableTools registers the query tools even when no
	// generation is published.
	//
	// It exists for the inspectors and registries that read a tool catalogue
	// before anybody has indexed anything: they can only score what
	// tools/list returns, and the fail-closed handshake of ADR 0067 returns
	// nothing to score. It changes what is *listed* and nothing else. There
	// is still no graph, so graph-dependent query tools return INDEX_NOT_READY
	// until one is published while graph_status reports an empty graph status.
	// index_project stays behind the same consent gate, and the handshake still
	// carries the repair instructions -- telling a client a graph exists when
	// none does would be the one lie this option must not tell.
	ExposeUnavailableTools bool
}

ServerOptions carries the choices a caller makes about the *shape* of the surface, as opposed to what answers from it. The zero value is the surface every existing constructor builds, so a caller that has nothing to say says nothing.

type StreamTransport added in v0.6.0

type StreamTransport struct {
	Stream io.ReadWriteCloser
}

StreamTransport serves one MCP session over a byte stream.

The SDK ships a transport for stdin/stdout and one for an in-memory pipe, and the stdio one hardcodes the process's own handles. A daemon accepting connections needs neither: it has a net.Conn per client and one server behind them, which is the whole point -- one mapped snapshot instead of one per client. The wire is the same newline-delimited JSON either way, so what is new here is only where the bytes come from.

The stream must unblock a pending Read when it is closed, because that is how the SDK cancels a session. A net.Conn does; os.Stdin does not, which is why the SDK's own stdio connection carries a reader goroutine and a channel that this one does not need.

func (*StreamTransport) Connect added in v0.6.0

func (transport *StreamTransport) Connect(context.Context) (sdkmcp.Connection, error)

Connect implements the sdkmcp.Transport interface.

Directories

Path Synopsis
Package tools implements the MCP tools Kivgraph answers questions with, along with their arguments, cursors, error codes and response shapes.
Package tools implements the MCP tools Kivgraph answers questions with, along with their arguments, cursors, error codes and response shapes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL