How smallnest/mcp-prompt-server-go works
Project Type and Purpose
• This is a backend service (an open-source MCP “tool” server) written in Go.
• It loads prompt templates (YAML/JSON), registers them as MCP tools via the mark3labs/mcp-go library, and exposes them over stdio or TCP for clients (Raycast, Cursor, Windsurf, etc.).
Main Components
a. CLI / Entry Point (cmd/main.go)
– Runs on server start, initializes configuration, kicks off prompt loader and server.
b. Server Layer (internal/server/server.go)
– Hosts the MCP tool service. Listens on stdio or network sockets, dispatches incoming requests.
c. Prompt Loader & Model (internal/prompt/loader.go & model.go)
– Scans prompts/ directory, parses YAML/JSON into in-memory Prompt structures.
– Supports hot-reload commands (reload_prompts).
d. Utility Module (internal/util/files.go)
– File system helpers for scanning directories, watching file changes.
e. Prompt Templates (prompts/*.yaml)
– Source of truth for all prompt definitions (names, descriptions, arguments, message bodies).
f. External Library (mark3labs/mcp-go)
– Under the hood, provides MCP tooling interfaces, registration APIs, request/response handling.
g. External Clients (Raycast, Cursor, Windsurf, Cherrystudio, etc.)
– Issue MCP calls (via stdio or TCP) to the running server executable.
Relationships & Data Flow
1. Startup
– main.go calls loader.LoadAll(prompts/) → builds in-memory prompt registry.
– Registers each prompt as an MCP tool via mcp-go APIs.
– Starts the MCP service in server.go, listening on stdio or port.
2. Runtime
– Client sends MCP request (tool name + arguments) → Server receives request →
– Look up corresponding prompt model → Fill template placeholders → Forward to LLM or embedded engine → Receive response → Stream back to client.
3. Hot-Reload
– On reload_prompts command or file-watch event → Loader rescans prompts/ → Unregister old tools → Register new/updated ones.
Architectural Patterns & Principles
• Separation of Concerns: CLI, server dispatch, prompt loading, and file utilities are in distinct packages.
• Plugin-Style Registration: Prompts auto-register as independent tools.
• Hot-Reload: Dynamic reconfiguration without restart.
• Modular Design: New prompt files add functionality without touching Go code.
Technologies & Frameworks
• Go modules (go.mod, go.sum)
• mark3labs/mcp-go for tool registration & request handling
• YAML/JSON parsing (Go stdlib or third-party lib)
• File I/O and (optional) fsnotify for hot-reload
• Standard I/O or TCP transport for MCP protocol