@@ -46,6 +46,7 @@ cmd/
goal/ → goal list/show (read-only)
journal/ → journal add
habit/ → habit track
+ mcp/ → MCP server command (stdio/sse/http transports)
internal/
client/ → Lunatask API client factory (uses system keyring)
config/ → TOML config at ~/.config/lune/config.toml
@@ -54,6 +55,10 @@ internal/
stats/ → Usage statistics helpers
ui/ → Lipgloss styles (Success, Warning, Error, H1, H2, FormatDate)
validate/ → Input validation (delegates to go-lunatask Parse* functions)
+ mcp/
+ shared/ → Provider types (AreaProvider, HabitProvider) and error helpers
+ tools/ → MCP tool handlers (task/, habit/, timestamp/)
+ resources/ → MCP resource handlers (areas/, habits/, notebooks/)
```
**Command flow**: `fang.Execute()` wraps Cobra with version/commit info and
@@ -85,6 +90,27 @@ see `cmd/task/add.go:56-63` for examples. Use `completion.Areas`, `completion.Go
etc. for config-based completions, or `completion.Static("val1", "val2")` for
fixed options.
+## MCP server patterns
+
+The `lune mcp` command starts a Model Context Protocol server for LLM tool
+integration. Architecture:
+
+- **Resources** (`internal/mcp/resources/`): Read-only data from config (areas,
+ habits, notebooks). Each has a `Handler` with `HandleRead` method.
+- **Tools** (`internal/mcp/tools/`): Actions that call the Lunatask API. Each
+ tool uses `*Input`/`*Output` structs with `jsonschema:"required"` tags for
+ MCP schema generation.
+- **Shared** (`internal/mcp/shared/`): Provider types decouple config from MCP
+ handlers; `ErrorResult()` returns structured tool errors.
+
+**Tool handler pattern**: Tools use `mcp.AddTool()` with typed input structs.
+Validation happens in `parse*Input()` functions returning `*mcp.CallToolResult`
+for errors (not Go errors). Parse functions call `lunatask.Parse*()` for enums
+and `dateutil.Parse()` for dates.
+
+**Config-driven tools**: `cfg.MCP.Tools.*` booleans enable/disable individual
+tools. All default to enabled via `cfg.MCP.MCPDefaults()`.
+
## Core dependencies
Reference docs via context7 or doc-agent when unsure:
@@ -107,6 +133,8 @@ Reference docs via context7 or doc-agent when unsure:
`/websites/pkg_go_dev_github_com_spf13_cobra`): CLI framework.
- `github.com/markusmobius/go-dateparser` (context7:
`/markusmobius/go-dateparser`): Natural language date parsing.
+- `github.com/modelcontextprotocol/go-sdk/mcp` (context7:
+ `/modelcontextprotocol/go-sdk`): MCP server SDK for LLM tool integration.
## Gotchas