.cursor/skills/mcp-go-sdk/SKILL.md
Build MCP servers using the official Go SDK (github.com/modelcontextprotocol/go-sdk/mcp). Use when implementing MCP tools, resources, server setup, transport configuration, or anything in internal/mcp/.
npx skillsauth add gtrig/LaightDB mcp-go-sdkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
SDK: github.com/modelcontextprotocol/go-sdk/mcp v1.5+
import "github.com/modelcontextprotocol/go-sdk/mcp"
server := mcp.NewServer(
&mcp.Implementation{Name: "laightdb", Version: "v0.1.0"},
nil, // *ServerOptions (capabilities, keep-alive, etc.)
)
Tools use typed Go structs for input. Struct fields use json and jsonschema tags:
type SearchInput struct {
Query string `json:"query" jsonschema:"search query text"`
Collection string `json:"collection,omitempty" jsonschema:"collection to search in"`
TopK int `json:"top_k,omitempty" jsonschema:"number of results (default 10)"`
Filters map[string]string `json:"filters,omitempty" jsonschema:"metadata key-value filters"`
Detail string `json:"detail,omitempty" jsonschema:"metadata, summary, or full"`
}
mcp.AddTool(server, &mcp.Tool{
Name: "search_context",
Description: "Search stored context using hybrid full-text and semantic search",
}, handleSearch)
func handleSearch(
ctx context.Context,
req *mcp.CallToolRequest,
input SearchInput,
) (*mcp.CallToolResult, any, error) {
// Business logic here...
// Return text content:
return &mcp.CallToolResult{
Content: []mcp.Content{
&mcp.TextContent{Text: resultJSON},
},
}, nil, nil
// Return error to client (not a Go error):
return &mcp.CallToolResult{
Content: []mcp.Content{
&mcp.TextContent{Text: "context not found"},
},
IsError: true,
}, nil, nil
}
Three return values: (*CallToolResult, OutputType, error)
error only for internal failures (transport/protocol)IsError: true on the result for user-facing tool errorsif err := server.Run(ctx, &mcp.StdioTransport{}); err != nil {
log.Fatal(err)
}
handler := mcp.NewStreamableHTTPHandler(
func(r *http.Request) *mcp.Server {
return server
},
&mcp.StreamableHTTPOptions{
// Stateless: true, // for stateless deployments
},
)
mux := http.NewServeMux()
mux.Handle("/mcp", handler)
http.ListenAndServe(":8080", mux)
Resources expose data that clients can browse/read:
mcp.AddResource(server, &mcp.Resource{
Name: "collections",
URI: "laightdb://collections",
Description: "List all context collections",
MimeType: "application/json",
}, handleListCollectionsResource)
func handleListCollectionsResource(
ctx context.Context,
req *mcp.ReadResourceRequest,
) (*mcp.ReadResourceResult, error) {
// Return resource content
return &mcp.ReadResourceResult{
Contents: []mcp.ResourceContents{
&mcp.TextResourceContents{
URI: "laightdb://collections",
MimeType: "application/json",
Text: collectionsJSON,
},
},
}, nil
}
For long operations (like bulk store), report progress:
func handleBulkStore(ctx context.Context, req *mcp.CallToolRequest, input BulkInput) (*mcp.CallToolResult, any, error) {
if token := mcp.ProgressToken(ctx); token != nil {
for i, item := range input.Items {
mcp.SendProgress(ctx, float64(i), float64(len(input.Items)))
// process item...
}
}
return &mcp.CallToolResult{...}, nil, nil
}
tools
Proactively loads relevant LaightDB context at the start of substantive work and persists concise rolling notes before wrapping up, using LaightDB MCP tools without waiting for the user to say "store" or "search". Use whenever this workspace has the LaightDB MCP server enabled and the user is doing multi-step implementation, debugging, or design that should survive across sessions.
tools
Vite/React UI for LaightDB: dashboard, search, and the 3D Explorer (/explorer) for context graphs and storage engine layout. Use when editing ui/src, Vite config, or REST client calls for graph overview / storage diagnostics.
development
Build an LSM-tree storage engine in Go with WAL, MemTable, SSTables, bloom filters, and compaction. Use when implementing or modifying internal/storage/ components, writing the WAL, MemTable, SSTable, compaction, or the storage engine orchestrator.
tools
Proactively loads relevant LaightDB context at the start of substantive work and persists concise rolling notes before wrapping up, using LaightDB MCP tools without waiting for the user to say "store" or "search". Use whenever this workspace has the LaightDB MCP server enabled and the user is doing multi-step implementation, debugging, or design that should survive across sessions.