Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tc = "test -p retrochat-core --verbose"
tt = "test -p retrochat-tui --verbose"
tcli = "test -p retrochat-cli --verbose"
tgui = "test -p retrochat-gui --verbose"
tmcp = "test -p retrochat-mcp --verbose"

# Build aliases
c = "check --workspace --verbose"
Expand All @@ -21,6 +22,7 @@ core = "run -p retrochat-core"
cli = "run -p retrochat-cli"
tui = "run -p retrochat-cli" # TUI is embedded in CLI
gui = "run -p retrochat-gui"
mcp = "run -p retrochat-mcp"

# Clean commands
clean-all = "clean --workspace"
108 changes: 103 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

## Project Structure

The project uses a Cargo workspace with 4 separate packages:
The project uses a Cargo workspace with 5 separate packages:

```
crates/
Expand All @@ -37,10 +37,17 @@ crates/
│ │ └── commands/ # CLI command handlers
│ └── tests/contract/ # CLI contract tests
└── retrochat-gui/ # Tauri desktop application
├── src/ # Tauri Rust backend
├── icons/ # App icons
└── tauri.conf.json # Tauri configuration
├── retrochat-gui/ # Tauri desktop application
│ ├── src/ # Tauri Rust backend
│ ├── icons/ # App icons
│ └── tauri.conf.json # Tauri configuration
└── retrochat-mcp/ # MCP server
├── src/
│ ├── main.rs # MCP server entry point
│ ├── server.rs # Server handler implementation
│ └── tools/ # MCP tool implementations
└── tests/ # Unit and integration tests

ui-react/ # React frontend for Tauri desktop app
├── src/ # React components and application code
Expand Down Expand Up @@ -74,6 +81,7 @@ cargo clippy-strict # Run clippy with -D warnings (clippy --workspace -- -D war
cargo cli # Run CLI (run -p retrochat-cli)
cargo tui # Launch TUI (run -p retrochat-cli, same as cli)
cargo gui # Run GUI (run -p retrochat-gui)
cargo mcp # Run MCP server (run -p retrochat-mcp)
```

#### Shell Scripts (in ./scripts)
Expand Down Expand Up @@ -240,4 +248,94 @@ Rust: Follow standard rustfmt conventions, use constitutional TDD approach
- **Shared Types**: Keep TypeScript types in sync with Rust types when communicating between frontend and backend
- **Error Handling**: Handle Tauri command errors gracefully in the UI

### MCP Server (retrochat-mcp/)

The project includes a Model Context Protocol (MCP) server that exposes RetroChat's query and analytics capabilities to AI assistants like Claude, Cursor, and others.

#### What is the MCP Server?
The MCP server provides a read-only interface for AI assistants to:
- Query and filter chat sessions
- Search messages across all sessions
- Retrieve detailed session information including messages
- Access analytics data for sessions

#### Running the MCP Server
```bash
# Using cargo alias
cargo mcp

# Or directly
cargo run -p retrochat-mcp

# With logging (logs go to stderr, won't interfere with stdio transport)
RUST_LOG=debug cargo mcp
```

#### Available Tools
The server exposes 4 MCP tools:

1. **list_sessions**: Query and filter chat sessions
- Supports filtering by provider, project, date range, message count
- Pagination support
- Sortable by various fields

2. **get_session_detail**: Get full session details including all messages
- Requires session UUID
- Returns complete message history

3. **search_messages**: Full-text search across all messages
- Supports filtering by providers, projects, date range
- Pagination support
- Returns message snippets with context

4. **get_session_analytics**: Get analytics for a specific session
- Requires session UUID
- Returns completed analytics or pending status

#### AI Assistant Configuration

**For Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"retrochat": {
"command": "/absolute/path/to/retrochat-mcp",
"args": [],
"env": {
"RUST_LOG": "info"
}
}
}
}
```

**For Cursor** (`.cursor/mcp.json` in project):
```json
{
"mcpServers": {
"retrochat": {
"command": "cargo",
"args": ["run", "-p", "retrochat-mcp"],
"cwd": "/absolute/path/to/retrochat"
}
}
}
```

#### Development Notes
- The MCP server is read-only (no write operations)
- Uses stdio transport for communication
- Logs to stderr to avoid interfering with MCP protocol
- Shares the same database as CLI/TUI (uses default database path)
- All responses are pretty-printed JSON for easy AI consumption

#### Testing
```bash
# Run MCP server tests
cargo tmcp

# Or full test command
cargo test -p retrochat-mcp --verbose
```

<!-- MANUAL ADDITIONS END -->
89 changes: 88 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/retrochat-tui",
"crates/retrochat-cli",
"crates/retrochat-gui",
"crates/retrochat-mcp",
]
resolver = "2"

Expand Down Expand Up @@ -64,6 +65,10 @@ log = "0.4.28"
atty = "0.2"
rusqlite = { version = "0.30", features = ["bundled", "backup"] }

# MCP
rmcp = { version = "0.11", features = ["server", "macros", "transport-io"] }
schemars = { version = "1.0", features = ["chrono04", "uuid1"] }

[workspace.package]
version = "0.1.0"
edition = "2021"
Expand Down
33 changes: 33 additions & 0 deletions crates/retrochat-mcp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "retrochat-mcp"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
description = "MCP server for RetroChat - exposes chat session query and analytics via Model Context Protocol"

[[bin]]
name = "retrochat-mcp"
path = "src/main.rs"

[dependencies]
retrochat-core = { path = "../retrochat-core" }

# MCP
rmcp = { workspace = true }
schemars = { workspace = true }

# Async & Core
tokio = { workspace = true }
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }
chrono = { workspace = true }

# Logging
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[dev-dependencies]
tempfile = "3.8"
Loading