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 ¶
- Variables
- func NewServer() *sdkmcp.Server
- func NewServerWithIndexer(indexer indexing.ProjectIndexer) *sdkmcp.Server
- func NewServerWithMetrics(registry *metrics.Registry) *sdkmcp.Server
- func NewServerWithMetricsAndSnapshotStore(registry *metrics.Registry, snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server
- func NewServerWithMetricsAndSnapshotStoreAndIndexer(registry *metrics.Registry, snapshotStore *hotsnapshot.SnapshotStore, ...) *sdkmcp.Server
- func NewServerWithMetricsAndSnapshotStoreAndIndexerOptions(registry *metrics.Registry, snapshotStore *hotsnapshot.SnapshotStore, ...) *sdkmcp.Server
- func NewServerWithObserver(observer tools.Observer) *sdkmcp.Server
- func NewServerWithObserverAndMetrics(observer tools.Observer, registry *metrics.Registry) *sdkmcp.Server
- func NewServerWithObserverAndMetricsAndSnapshotStore(observer tools.Observer, registry *metrics.Registry, ...) *sdkmcp.Server
- func NewServerWithObserverAndSnapshotStore(observer tools.Observer, snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server
- func NewServerWithSnapshotStore(snapshotStore *hotsnapshot.SnapshotStore) *sdkmcp.Server
- func NewServerWithSnapshotStoreAndIndexer(snapshotStore *hotsnapshot.SnapshotStore, indexer indexing.ProjectIndexer) *sdkmcp.Server
- func Run(ctx context.Context) error
- func RunWithMetrics(ctx context.Context, registry *metrics.Registry) error
- func RunWithMetricsAndSnapshotStore(ctx context.Context, registry *metrics.Registry, ...) error
- func RunWithMetricsAndSnapshotStoreAndIndexer(ctx context.Context, registry *metrics.Registry, ...) error
- func RunWithMetricsAndSnapshotStoreAndIndexerOptions(ctx context.Context, registry *metrics.Registry, ...) error
- func RunWithSnapshotStore(ctx context.Context, snapshotStore *hotsnapshot.SnapshotStore) error
- func RunWithSnapshotStoreAndIndexer(ctx context.Context, snapshotStore *hotsnapshot.SnapshotStore, ...) error
- type IndexJobs
- type ServerOptions
- type StreamTransport
Constants ¶
This section is empty.
Variables ¶
var ErrNoStream = errors.New("mcp: transport has no stream")
ErrNoStream is returned by a StreamTransport with nothing to talk over.
Functions ¶
func NewServerWithIndexer ¶
func NewServerWithIndexer(indexer indexing.ProjectIndexer) *sdkmcp.Server
NewServerWithIndexer creates a server that also exposes the explicit permission-gated indexing controls.
func NewServerWithMetrics ¶
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 ¶
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 ¶
Run serves one MCP session over the process stdin/stdout transport with a process-local metrics registry available to graph_status.
func RunWithMetrics ¶
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 indexing controls.
Types ¶
type IndexJobs ¶ added in v0.10.0
IndexJobs is the shared asynchronous indexing registry used by a hosting process. The alias keeps daemon wiring out of the tool implementation package.
func NewIndexJobs ¶ added in v0.10.0
func NewIndexJobs(indexer indexing.ProjectIndexer) *IndexJobs
NewIndexJobs creates one asynchronous indexing registry for a hosting process. A daemon shares it across every session it accepts.
func NewIndexJobsWithContext ¶ added in v0.10.0
func NewIndexJobsWithContext(ctx context.Context, indexer indexing.ProjectIndexer) *IndexJobs
NewIndexJobsWithContext binds asynchronous indexing to a hosting process.
type ServerOptions ¶ added in v0.9.2
type ServerOptions struct {
// 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.
// Both indexing entry points stay 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
// IndexJobs shares asynchronous indexing state across the MCP sessions a
// daemon creates. Nil gives this server its own bounded registry; a caller
// that constructs multiple servers must share one explicitly.
IndexJobs *tools.IndexJobs
}
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. |