
netstar-labs/mcp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
A Model Context Protocol (MCP) server in Go — standard library only, zero dependencies.
概要
No third-party dependencies, no code generation, no reflection tricks. go.mod has no require block and it stays that way. The package MCP (stdio, unix socket) and it (the Client), sharing one Framer / JSON-RPC / protocol core across both roles — which is what lets one service front another. - — docs/introduction.md · docs/executive-summary.md - — docs/architecture.md (this README is the reference; the docs are the guided tour) - — docs/userguide.md - — example/README.md Module github.com/netstar-labs/mcp — the root package mcp is the importable library; app/mcpd is the reference daemon. Capabilities are derived from what is actually registered rather than declared separately, so the advertisement cannot drift from the implementation. — line-delimited JSON on stdin/stdout, as the MCP stdio transport specifies. Nothing else in the process may write to stdout; the default logger goes to stderr.
README
以下は原文 README の抜粋です。原文を見る。
mcp — an MCP server and client in Go, standard library only
No third-party dependencies, no code generation, no reflection tricks. go.mod
has no require block and it stays that way. The package serves MCP (stdio,
unix socket) and consumes it (the Client), sharing one Framer / JSON-RPC /
protocol core across both roles — which is what lets one service front another.
mcp/
jsonrpc.go JSON-RPC 2.0 wire types, ID normalisation, error codes
framing.go line framing (NDJSON) and Content-Length framing
protocol.go MCP data types for all three protocol revisions
server.go registry, capability derivation, pagination, lifecycle
session.go per-connection state machine, read/write loops, outbound calls
dispatch.go method handlers, URI template matching
transport.go stdio, Unix sockets, systemd activation, accept loop
client.go MCP client: Dial, Initialize, ListTools, CallTool, server→client dispatch
peercred_linux.go SO_PEERCRED
peercred_other.go fallback
umask_unix.go socket creation under a umask
server_test.go protocol conformance tests over a real socket
client_test.go client↔server round trip over an in-memory pipe
harden_test.go limits, quotas, deadlines, injection, cache invalidation
audit_fixes_test.go regressions: cursor-cache bound, large-id keys, dup Content-Length
protocol_content_test.go Content constructors, SessionFromContext
transport_test.go systemd no-activation paths
helpers_test.go test helpers (short socket paths)
bench_test.go benchmarks
app/mcpd/ reference daemon (the mcpd binary)
example/stdio/ minimal runnable server (one echo tool over stdio)
docs/ introduction · executive-summary · architecture · userguide · plan/
build/mcp cross-compile + package + install the daemon
Documentation
- Start here — docs/introduction.md · docs/executive-summary.md
- Deep dive — docs/architecture.md (this README is the reference; the docs are the guided tour)
- Operations — docs/userguide.md
- Examples — example/README.md
Module github.com/netstar-labs/mcp — the root package mcp is the importable
library; app/mcpd is the reference daemon.
Usage
srv := mcp.New(mcp.Options{Name: "mcpd", Version: "1.0.0"})
srv.AddTool(mcp.Tool{
Name: "sha256",
InputSchema: json.RawMessage(`{"type":"object","properties":{"input":{"type":"string"}},"required":["input"]}`),
}, func(ctx context.Context, s *mcp.Session, args json.RawMessage) (*mcp.CallToolResult, error) {
var in struct{ Input string `json:"input"` }
if err := json.Unmarshal(args, &in); err != nil {
return mcp.ToolError("invalid arguments: %v", err), nil
}
sum := sha256.Sum256([]byte(in.Input))
return mcp.ToolText("%x", sum), nil
})
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →