mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-13 19:20:06 +00:00
2.7 KiB
2.7 KiB
MCPHost Development Context
Build/Test Commands
- Build:
go build -o output/mcphostor use./contribute/build.sh - Test:
go test ./...(run all tests) - Test single package:
go test ./pkg/llm/anthropic - Lint:
go vet ./...(built-in Go linter) - Format:
go fmt ./... - Dependencies:
go mod tidy
Code Style Guidelines
- Package structure:
pkg/for reusable packages,cmd/for CLI commands - Imports: Standard library first, then third-party, then local packages with blank lines between groups
- Naming: Use camelCase for unexported, PascalCase for exported; descriptive names (e.g.,
CreateMessage,mcpClients) - Interfaces: Keep small and focused (e.g.,
llm.Provider,llm.Message) - Error handling: Always check errors, wrap with context using
fmt.Errorf("context: %v", err) - Logging: Use
github.com/charmbracelet/logwith structured logging:log.Info("message", "key", value) - Types: Prefer
anyoverinterface{}(modernize hint from linter) - JSON tags: Use snake_case for JSON fields, include omitempty where appropriate
- Context: Always pass
context.Contextas first parameter for operations that may block
Architecture Notes
- Multi-provider LLM support (Anthropic, OpenAI, Ollama, Google)
- MCP (Model Context Protocol) client-server architecture for tool integration
- Provider pattern for LLM abstraction with common
llm.Providerinterface - History management with message pruning based on configurable window size
- Tool calling support across all providers with unified
llm.Toolinterface
MCP Configuration Schema
MCPHost supports a simplified configuration schema with two server types:
New Simplified Format
- Local servers (
"type": "local"): Run commands locally via stdio transportcommand: Array of command and arguments (e.g.,["npx", "server", "args"])environment: Key-value map of environment variables
- Remote servers (
"type": "remote"): Connect via StreamableHTTP transporturl: Server endpoint URL- Automatically uses StreamableHTTP for optimal performance
Legacy Format Support
- Maintains full backward compatibility with existing configurations
- Automatic detection and conversion of legacy formats
- Custom
UnmarshalJSONmethod handles format migration seamlessly
Transport Mapping
"local"type →stdiotransport (launches local processes)"remote"type →streamabletransport (StreamableHTTP protocol)- Legacy
transportfield still supported for backward compatibility
Configuration Files
- Primary:
~/.mcphost.ymlor~/.mcphost.json - Legacy:
~/.mcp.ymlor~/.mcp.json - Custom location via
--configflag