trak_flow 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.envrc +3 -0
- data/CHANGELOG.md +69 -0
- data/COMMITS.md +196 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +281 -0
- data/README.md +479 -0
- data/Rakefile +16 -0
- data/bin/tf +6 -0
- data/bin/tf_mcp +81 -0
- data/docs/.keep +0 -0
- data/docs/api/database.md +434 -0
- data/docs/api/ruby-library.md +349 -0
- data/docs/api/task-model.md +341 -0
- data/docs/assets/stylesheets/extra.css +53 -0
- data/docs/assets/trak_flow.jpg +0 -0
- data/docs/cli/admin-commands.md +369 -0
- data/docs/cli/dependency-commands.md +321 -0
- data/docs/cli/label-commands.md +222 -0
- data/docs/cli/overview.md +163 -0
- data/docs/cli/plan-commands.md +344 -0
- data/docs/cli/task-commands.md +333 -0
- data/docs/core-concepts/dependencies.md +232 -0
- data/docs/core-concepts/labels.md +217 -0
- data/docs/core-concepts/overview.md +178 -0
- data/docs/core-concepts/plans-workflows.md +264 -0
- data/docs/core-concepts/tasks.md +205 -0
- data/docs/getting-started/configuration.md +120 -0
- data/docs/getting-started/installation.md +79 -0
- data/docs/getting-started/quick-start.md +245 -0
- data/docs/index.md +169 -0
- data/docs/mcp/integration.md +302 -0
- data/docs/mcp/overview.md +206 -0
- data/docs/mcp/resources.md +284 -0
- data/docs/mcp/tools.md +457 -0
- data/examples/basic_usage.rb +365 -0
- data/examples/cli_demo.sh +314 -0
- data/examples/mcp/Gemfile +9 -0
- data/examples/mcp/Gemfile.lock +226 -0
- data/examples/mcp/http_demo.rb +232 -0
- data/examples/mcp/stdio_demo.rb +146 -0
- data/lib/trak_flow/cli/admin_commands.rb +136 -0
- data/lib/trak_flow/cli/config_commands.rb +260 -0
- data/lib/trak_flow/cli/dep_commands.rb +71 -0
- data/lib/trak_flow/cli/label_commands.rb +76 -0
- data/lib/trak_flow/cli/main_commands.rb +386 -0
- data/lib/trak_flow/cli/plan_commands.rb +185 -0
- data/lib/trak_flow/cli/workflow_commands.rb +133 -0
- data/lib/trak_flow/cli.rb +110 -0
- data/lib/trak_flow/config/defaults.yml +114 -0
- data/lib/trak_flow/config/section.rb +74 -0
- data/lib/trak_flow/config.rb +276 -0
- data/lib/trak_flow/graph/dependency_graph.rb +288 -0
- data/lib/trak_flow/id_generator.rb +52 -0
- data/lib/trak_flow/mcp/resources/base_resource.rb +25 -0
- data/lib/trak_flow/mcp/resources/dependency_graph.rb +31 -0
- data/lib/trak_flow/mcp/resources/label_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/plan_by_id.rb +27 -0
- data/lib/trak_flow/mcp/resources/plan_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/task_by_id.rb +31 -0
- data/lib/trak_flow/mcp/resources/task_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/task_next.rb +30 -0
- data/lib/trak_flow/mcp/resources/workflow_by_id.rb +27 -0
- data/lib/trak_flow/mcp/resources/workflow_list.rb +21 -0
- data/lib/trak_flow/mcp/server.rb +140 -0
- data/lib/trak_flow/mcp/tools/base_tool.rb +29 -0
- data/lib/trak_flow/mcp/tools/comment_add.rb +33 -0
- data/lib/trak_flow/mcp/tools/dep_add.rb +34 -0
- data/lib/trak_flow/mcp/tools/dep_remove.rb +25 -0
- data/lib/trak_flow/mcp/tools/label_add.rb +28 -0
- data/lib/trak_flow/mcp/tools/label_remove.rb +25 -0
- data/lib/trak_flow/mcp/tools/plan_add_step.rb +35 -0
- data/lib/trak_flow/mcp/tools/plan_create.rb +33 -0
- data/lib/trak_flow/mcp/tools/plan_run.rb +58 -0
- data/lib/trak_flow/mcp/tools/plan_start.rb +58 -0
- data/lib/trak_flow/mcp/tools/task_block.rb +27 -0
- data/lib/trak_flow/mcp/tools/task_close.rb +26 -0
- data/lib/trak_flow/mcp/tools/task_create.rb +51 -0
- data/lib/trak_flow/mcp/tools/task_defer.rb +27 -0
- data/lib/trak_flow/mcp/tools/task_start.rb +25 -0
- data/lib/trak_flow/mcp/tools/task_update.rb +36 -0
- data/lib/trak_flow/mcp/tools/workflow_discard.rb +28 -0
- data/lib/trak_flow/mcp/tools/workflow_summarize.rb +34 -0
- data/lib/trak_flow/mcp.rb +38 -0
- data/lib/trak_flow/models/comment.rb +71 -0
- data/lib/trak_flow/models/dependency.rb +96 -0
- data/lib/trak_flow/models/label.rb +90 -0
- data/lib/trak_flow/models/task.rb +188 -0
- data/lib/trak_flow/storage/database.rb +638 -0
- data/lib/trak_flow/storage/jsonl.rb +259 -0
- data/lib/trak_flow/time_parser.rb +15 -0
- data/lib/trak_flow/version.rb +5 -0
- data/lib/trak_flow.rb +100 -0
- data/mkdocs.yml +143 -0
- metadata +392 -0
data/docs/index.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# TrakFlow
|
|
2
|
+
|
|
3
|
+
<div class="grid" markdown>
|
|
4
|
+
|
|
5
|
+
<div markdown>
|
|
6
|
+
|
|
7
|
+
{ width="100%" }
|
|
8
|
+
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div markdown>
|
|
12
|
+
|
|
13
|
+
**A distributed task tracking system for Robots with a DAG-based workflow engine.**
|
|
14
|
+
|
|
15
|
+
TrakFlow helps Robots (what some might call AI agents) manage complex, multi-step work pipelines without losing track of what they need to do.
|
|
16
|
+
|
|
17
|
+
| | |
|
|
18
|
+
|---|---|
|
|
19
|
+
| :material-git: Git-Backed | :material-database: SQLite Cache |
|
|
20
|
+
| :material-identifier: Hash-Based IDs | :material-graph: Dependency Graph |
|
|
21
|
+
| :material-robot: MCP Server | :material-workflow: Plans & Workflows |
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<p align="center" markdown>
|
|
28
|
+
[:material-download: Install](getting-started/installation.md){ .md-button .md-button--primary }
|
|
29
|
+
[:material-rocket-launch: Quick Start](getting-started/quick-start.md){ .md-button }
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
### Git-Backed Persistence
|
|
37
|
+
|
|
38
|
+
Tasks are stored as human-readable JSONL files that live alongside your code. No external database server required. Every change is versioned through Git, giving you full history, branching, and collaboration capabilities. Roll back mistakes, review task history in PRs, and keep your project management data where it belongs—in your repository.
|
|
39
|
+
|
|
40
|
+
### Hash-Based IDs
|
|
41
|
+
|
|
42
|
+
TrakFlow generates unique task IDs using content hashing, eliminating merge conflicts when multiple AI agents or team members create tasks simultaneously. No central ID server needed. IDs are deterministic and portable, making it safe to work offline and sync later without coordination overhead.
|
|
43
|
+
|
|
44
|
+
### SQLite Cache
|
|
45
|
+
|
|
46
|
+
While JSONL provides persistence, a local SQLite database delivers blazing-fast queries with millisecond response times. Full-text search, indexed lookups by status, priority, labels, and dependencies—all optimized for the rapid-fire queries that AI agents generate. The cache rebuilds automatically from JSONL on each session.
|
|
47
|
+
|
|
48
|
+
### Dependency Graph
|
|
49
|
+
|
|
50
|
+
Model complex task relationships with a directed acyclic graph (DAG). Define blocking dependencies, related tasks, and parent-child hierarchies. TrakFlow automatically detects cycles, identifies tasks ready for work (no open blockers), and visualizes your workflow as a graph. Perfect for multi-step pipelines where order matters.
|
|
51
|
+
|
|
52
|
+
### MCP Server
|
|
53
|
+
|
|
54
|
+
Expose your task data to AI agents through the Model Context Protocol (MCP) standard. Compatible with Claude Desktop, VS Code extensions, and any MCP-enabled application. Supports both STDIO transport for local development and HTTP/SSE for remote access. Agents can create, query, and update tasks programmatically.
|
|
55
|
+
|
|
56
|
+
### Plans & Workflows
|
|
57
|
+
|
|
58
|
+
Define reusable workflow blueprints (Plans) and instantiate them as running Workflows. Perfect for repeatable processes like deployments, code reviews, or onboarding checklists. Choose persistent Workflows for audit trails or ephemeral Workflows for temporary operations that auto-clean after completion.
|
|
59
|
+
|
|
60
|
+
## Quick Example
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Initialize TrakFlow in your project
|
|
64
|
+
tf init
|
|
65
|
+
|
|
66
|
+
# Create a task
|
|
67
|
+
tf create "Implement user authentication" -t feature -p 1
|
|
68
|
+
|
|
69
|
+
# Create a Plan (workflow blueprint)
|
|
70
|
+
tf plan create "Deploy to Production"
|
|
71
|
+
|
|
72
|
+
# Add steps to the Plan
|
|
73
|
+
tf plan add tf-abc123 "Run tests"
|
|
74
|
+
tf plan add tf-abc123 "Build artifacts"
|
|
75
|
+
tf plan add tf-abc123 "Deploy"
|
|
76
|
+
|
|
77
|
+
# Execute the Plan as a Workflow
|
|
78
|
+
tf plan start tf-abc123
|
|
79
|
+
|
|
80
|
+
# Find tasks ready for work
|
|
81
|
+
tf ready
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Three Ways to Use TrakFlow
|
|
85
|
+
|
|
86
|
+
### 1. CLI Tool
|
|
87
|
+
|
|
88
|
+
Use `tf` commands to manage tasks from the terminal:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
tf create "Fix login bug" -t bug -p 1
|
|
92
|
+
tf list --status open
|
|
93
|
+
tf close tf-abc123
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 2. Ruby Library
|
|
97
|
+
|
|
98
|
+
Integrate TrakFlow directly into your Ruby applications:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
require 'trak_flow'
|
|
102
|
+
|
|
103
|
+
TrakFlow.ensure_initialized!
|
|
104
|
+
db = TrakFlow::Storage::Database.new
|
|
105
|
+
db.connect
|
|
106
|
+
|
|
107
|
+
task = TrakFlow::Models::Task.new(
|
|
108
|
+
title: "Automated task",
|
|
109
|
+
type: "task",
|
|
110
|
+
priority: 2
|
|
111
|
+
)
|
|
112
|
+
db.insert_task(task)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 3. MCP Server
|
|
116
|
+
|
|
117
|
+
Expose TrakFlow to AI agents via the Model Context Protocol:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Start the MCP server (STDIO transport)
|
|
121
|
+
tf_mcp
|
|
122
|
+
|
|
123
|
+
# Or HTTP transport
|
|
124
|
+
tf_mcp --http --port 3333
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Architecture Overview
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
.trak_flow/
|
|
131
|
+
├── trak_flow.db # SQLite database (gitignored)
|
|
132
|
+
├── issues.jsonl # Git-tracked source of truth
|
|
133
|
+
├── config.json # Project configuration
|
|
134
|
+
└── .gitignore
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
TrakFlow uses a three-layer architecture:
|
|
138
|
+
|
|
139
|
+
1. **CLI/MCP Interface** - User and agent-facing commands
|
|
140
|
+
2. **SQLite Database** - Fast local queries and indexing
|
|
141
|
+
3. **JSONL Format** - Git-tracked persistence for collaboration
|
|
142
|
+
|
|
143
|
+
## Getting Started
|
|
144
|
+
|
|
145
|
+
<div class="grid cards" markdown>
|
|
146
|
+
|
|
147
|
+
- :material-download:{ .lg .middle } **[Installation](getting-started/installation.md)**
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
Install TrakFlow via RubyGems or from source
|
|
152
|
+
|
|
153
|
+
- :material-rocket-launch:{ .lg .middle } **[Quick Start](getting-started/quick-start.md)**
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
Get up and running in minutes
|
|
158
|
+
|
|
159
|
+
- :material-cog:{ .lg .middle } **[Configuration](getting-started/configuration.md)**
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
Customize TrakFlow for your project
|
|
164
|
+
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
TrakFlow is released under the MIT License.
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# MCP Integration Guide
|
|
2
|
+
|
|
3
|
+
This guide covers integrating TrakFlow's MCP server with various AI applications and development tools.
|
|
4
|
+
|
|
5
|
+
## Claude Desktop
|
|
6
|
+
|
|
7
|
+
### Configuration
|
|
8
|
+
|
|
9
|
+
Add TrakFlow to your Claude Desktop configuration file:
|
|
10
|
+
|
|
11
|
+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
12
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"trak_flow": {
|
|
18
|
+
"command": "tf",
|
|
19
|
+
"args": ["mcp", "start"],
|
|
20
|
+
"cwd": "/path/to/your/project"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Usage
|
|
27
|
+
|
|
28
|
+
Once configured, Claude can:
|
|
29
|
+
|
|
30
|
+
- View your tasks: "What tasks are currently open?"
|
|
31
|
+
- Create tasks: "Create a task to fix the login bug"
|
|
32
|
+
- Update status: "Mark task tf-abc123 as in progress"
|
|
33
|
+
- Find work: "What should I work on next?"
|
|
34
|
+
|
|
35
|
+
## VS Code / Cursor
|
|
36
|
+
|
|
37
|
+
### With MCP Extension
|
|
38
|
+
|
|
39
|
+
If using an MCP-enabled extension:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"mcp.servers": {
|
|
44
|
+
"trak_flow": {
|
|
45
|
+
"command": "tf",
|
|
46
|
+
"args": ["mcp", "start"],
|
|
47
|
+
"cwd": "${workspaceFolder}"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### With Continue.dev
|
|
54
|
+
|
|
55
|
+
Add to your `.continue/config.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": [
|
|
60
|
+
{
|
|
61
|
+
"name": "trak_flow",
|
|
62
|
+
"command": "tf",
|
|
63
|
+
"args": ["mcp", "start"]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Ruby Applications
|
|
70
|
+
|
|
71
|
+
### Using ruby_llm-mcp
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
require 'ruby_llm'
|
|
75
|
+
require 'ruby_llm/mcp'
|
|
76
|
+
|
|
77
|
+
# Connect via STDIO
|
|
78
|
+
client = RubyLLM::MCP::Client.new(
|
|
79
|
+
transport_type: :stdio,
|
|
80
|
+
command: ["tf", "mcp", "start"],
|
|
81
|
+
working_dir: "/path/to/project"
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# List available tools
|
|
85
|
+
client.tools.each do |tool|
|
|
86
|
+
puts "#{tool.name}: #{tool.description}"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Create a task
|
|
90
|
+
create_tool = client.tool("task_create")
|
|
91
|
+
result = create_tool.execute(
|
|
92
|
+
title: "Implement feature",
|
|
93
|
+
type: "feature",
|
|
94
|
+
priority: 1
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
puts "Created task: #{result['task']['id']}"
|
|
98
|
+
|
|
99
|
+
# Get ready tasks
|
|
100
|
+
ready_tool = client.tool("ready_tasks")
|
|
101
|
+
ready = ready_tool.execute
|
|
102
|
+
puts "Ready to work on: #{ready['tasks'].map { |t| t['title'] }}"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Using HTTP Transport
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
require 'ruby_llm/mcp'
|
|
109
|
+
|
|
110
|
+
# Connect via HTTP/SSE
|
|
111
|
+
client = RubyLLM::MCP::Client.new(
|
|
112
|
+
transport_type: :sse,
|
|
113
|
+
url: "http://localhost:9292/sse"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Same API as STDIO
|
|
117
|
+
tools = client.tools
|
|
118
|
+
resources = client.resources
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Python Applications
|
|
122
|
+
|
|
123
|
+
### Using mcp Package
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import asyncio
|
|
127
|
+
from mcp import ClientSession, StdioServerParameters
|
|
128
|
+
from mcp.client.stdio import stdio_client
|
|
129
|
+
|
|
130
|
+
async def main():
|
|
131
|
+
server_params = StdioServerParameters(
|
|
132
|
+
command="tf",
|
|
133
|
+
args=["mcp", "start"],
|
|
134
|
+
cwd="/path/to/project"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
async with stdio_client(server_params) as (read, write):
|
|
138
|
+
async with ClientSession(read, write) as session:
|
|
139
|
+
# Initialize
|
|
140
|
+
await session.initialize()
|
|
141
|
+
|
|
142
|
+
# List tools
|
|
143
|
+
tools = await session.list_tools()
|
|
144
|
+
for tool in tools.tools:
|
|
145
|
+
print(f"{tool.name}: {tool.description}")
|
|
146
|
+
|
|
147
|
+
# Create a task
|
|
148
|
+
result = await session.call_tool(
|
|
149
|
+
"task_create",
|
|
150
|
+
{"title": "Task from Python", "priority": 1}
|
|
151
|
+
)
|
|
152
|
+
print(result)
|
|
153
|
+
|
|
154
|
+
asyncio.run(main())
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## JavaScript/TypeScript
|
|
158
|
+
|
|
159
|
+
### Using @modelcontextprotocol/sdk
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
163
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
164
|
+
|
|
165
|
+
const transport = new StdioClientTransport({
|
|
166
|
+
command: 'tf',
|
|
167
|
+
args: ['mcp', 'start'],
|
|
168
|
+
cwd: '/path/to/project'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const client = new Client({
|
|
172
|
+
name: 'my-app',
|
|
173
|
+
version: '1.0.0'
|
|
174
|
+
}, {
|
|
175
|
+
capabilities: {}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
await client.connect(transport);
|
|
179
|
+
|
|
180
|
+
// List tools
|
|
181
|
+
const { tools } = await client.listTools();
|
|
182
|
+
console.log('Available tools:', tools.map(t => t.name));
|
|
183
|
+
|
|
184
|
+
// Create a task
|
|
185
|
+
const result = await client.callTool('task_create', {
|
|
186
|
+
title: 'Task from JavaScript',
|
|
187
|
+
type: 'feature'
|
|
188
|
+
});
|
|
189
|
+
console.log('Created:', result);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## HTTP API (Direct)
|
|
193
|
+
|
|
194
|
+
For applications that can't use MCP directly, start the HTTP server:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
tf mcp start --http --port 9292
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Endpoints
|
|
201
|
+
|
|
202
|
+
| Endpoint | Method | Description |
|
|
203
|
+
|----------|--------|-------------|
|
|
204
|
+
| `/sse` | GET | SSE connection for MCP messages |
|
|
205
|
+
| `/messages` | POST | Send MCP request |
|
|
206
|
+
|
|
207
|
+
### Example with curl
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Initialize session (returns session ID in SSE stream)
|
|
211
|
+
curl -N http://localhost:9292/sse &
|
|
212
|
+
|
|
213
|
+
# Send a tool call
|
|
214
|
+
curl -X POST http://localhost:9292/messages \
|
|
215
|
+
-H "Content-Type: application/json" \
|
|
216
|
+
-d '{
|
|
217
|
+
"method": "tools/call",
|
|
218
|
+
"params": {
|
|
219
|
+
"name": "task_list",
|
|
220
|
+
"arguments": {"status": "open"}
|
|
221
|
+
}
|
|
222
|
+
}'
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Custom Integration
|
|
226
|
+
|
|
227
|
+
### Starting the Server Programmatically
|
|
228
|
+
|
|
229
|
+
```ruby
|
|
230
|
+
require 'trak_flow/mcp'
|
|
231
|
+
|
|
232
|
+
# Create server with custom configuration
|
|
233
|
+
server = TrakFlow::Mcp::Server.new(
|
|
234
|
+
db_path: "/custom/path/trak_flow.db",
|
|
235
|
+
jsonl_path: "/custom/path/issues.jsonl"
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# STDIO mode
|
|
239
|
+
server.run
|
|
240
|
+
|
|
241
|
+
# Or HTTP mode
|
|
242
|
+
server.run_http(
|
|
243
|
+
port: 9292,
|
|
244
|
+
host: "0.0.0.0"
|
|
245
|
+
)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Adding Custom Tools
|
|
249
|
+
|
|
250
|
+
```ruby
|
|
251
|
+
require 'trak_flow/mcp'
|
|
252
|
+
|
|
253
|
+
server = TrakFlow::Mcp::Server.new
|
|
254
|
+
|
|
255
|
+
# Add a custom tool
|
|
256
|
+
server.add_tool(
|
|
257
|
+
name: "my_custom_tool",
|
|
258
|
+
description: "Does something custom",
|
|
259
|
+
parameters: {
|
|
260
|
+
param1: { type: "string", required: true }
|
|
261
|
+
}
|
|
262
|
+
) do |params|
|
|
263
|
+
# Tool implementation
|
|
264
|
+
{ result: "Custom result for #{params[:param1]}" }
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
server.run
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Best Practices
|
|
271
|
+
|
|
272
|
+
### Performance
|
|
273
|
+
|
|
274
|
+
1. **Reuse connections** - Don't create new clients for each request
|
|
275
|
+
2. **Use STDIO for local** - Lower overhead than HTTP
|
|
276
|
+
3. **Cache resource data** - Resources are snapshots, cache appropriately
|
|
277
|
+
|
|
278
|
+
### Error Handling
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
begin
|
|
282
|
+
result = tool.execute(title: "New task")
|
|
283
|
+
rescue RubyLLM::MCP::ToolError => e
|
|
284
|
+
puts "Tool error: #{e.message}"
|
|
285
|
+
rescue RubyLLM::MCP::ConnectionError => e
|
|
286
|
+
puts "Connection lost: #{e.message}"
|
|
287
|
+
end
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Concurrency
|
|
291
|
+
|
|
292
|
+
The MCP server handles concurrent requests, but consider:
|
|
293
|
+
|
|
294
|
+
1. **SQLite limitations** - Write operations are serialized
|
|
295
|
+
2. **JSONL sync** - Writes are atomic but sequential
|
|
296
|
+
3. **Long operations** - Consider timeouts for complex queries
|
|
297
|
+
|
|
298
|
+
### Security
|
|
299
|
+
|
|
300
|
+
1. **Local only by default** - HTTP binds to 127.0.0.1
|
|
301
|
+
2. **No auth built-in** - Add authentication at network layer
|
|
302
|
+
3. **Read project data only** - Server can't access arbitrary files
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# MCP Server Overview
|
|
2
|
+
|
|
3
|
+
TrakFlow includes a Model Context Protocol (MCP) server that allows AI agents and LLM-powered applications to interact with your task data.
|
|
4
|
+
|
|
5
|
+
## What is MCP?
|
|
6
|
+
|
|
7
|
+
The [Model Context Protocol](https://modelcontextprotocol.io/) is an open standard for connecting AI applications to external data sources and tools. TrakFlow's MCP server exposes:
|
|
8
|
+
|
|
9
|
+
- **Tools** - Actions agents can perform (create, update, list tasks)
|
|
10
|
+
- **Resources** - Data agents can read (task lists, dependencies)
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
### STDIO Transport (Recommended for Local Use)
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
require 'trak_flow'
|
|
18
|
+
require 'trak_flow/mcp'
|
|
19
|
+
|
|
20
|
+
# Start the MCP server over STDIO
|
|
21
|
+
TrakFlow::Mcp::Server.new.run
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### HTTP/SSE Transport (For Remote Access)
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
require 'trak_flow'
|
|
28
|
+
require 'trak_flow/mcp'
|
|
29
|
+
|
|
30
|
+
# Start with HTTP/SSE transport
|
|
31
|
+
server = TrakFlow::Mcp::Server.new
|
|
32
|
+
server.run_http(port: 9292)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
graph LR
|
|
39
|
+
subgraph "AI Application"
|
|
40
|
+
LLM[LLM]
|
|
41
|
+
Client[MCP Client]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
subgraph "TrakFlow MCP Server"
|
|
45
|
+
Server[FastMcp Server]
|
|
46
|
+
Tools[Tools]
|
|
47
|
+
Resources[Resources]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
subgraph "TrakFlow Core"
|
|
51
|
+
DB[(SQLite)]
|
|
52
|
+
JSONL[issues.jsonl]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
LLM <--> Client
|
|
56
|
+
Client <-->|STDIO or HTTP/SSE| Server
|
|
57
|
+
Server --> Tools
|
|
58
|
+
Server --> Resources
|
|
59
|
+
Tools --> DB
|
|
60
|
+
Resources --> DB
|
|
61
|
+
DB --> JSONL
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Transport Options
|
|
65
|
+
|
|
66
|
+
### STDIO Transport
|
|
67
|
+
|
|
68
|
+
Best for:
|
|
69
|
+
- Local development
|
|
70
|
+
- IDE integrations (VS Code, Cursor)
|
|
71
|
+
- Single-user setups
|
|
72
|
+
- Command-line tools
|
|
73
|
+
|
|
74
|
+
Communication happens through standard input/output streams.
|
|
75
|
+
|
|
76
|
+
### HTTP/SSE Transport
|
|
77
|
+
|
|
78
|
+
Best for:
|
|
79
|
+
- Remote access
|
|
80
|
+
- Multi-client scenarios
|
|
81
|
+
- Web applications
|
|
82
|
+
- API integrations
|
|
83
|
+
|
|
84
|
+
Uses HTTP for requests and Server-Sent Events (SSE) for real-time updates.
|
|
85
|
+
|
|
86
|
+
## Available Tools
|
|
87
|
+
|
|
88
|
+
| Tool | Description |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `task_create` | Create a new task |
|
|
91
|
+
| `task_list` | List tasks with filters |
|
|
92
|
+
| `task_show` | Get task details |
|
|
93
|
+
| `task_update` | Modify a task |
|
|
94
|
+
| `task_start` | Begin working on a task |
|
|
95
|
+
| `task_close` | Complete a task |
|
|
96
|
+
| `task_block` | Mark as blocked |
|
|
97
|
+
| `task_reopen` | Reopen a closed task |
|
|
98
|
+
| `plan_create` | Create a Plan blueprint |
|
|
99
|
+
| `plan_start` | Start a Workflow |
|
|
100
|
+
| `dep_add` | Add dependency |
|
|
101
|
+
| `dep_remove` | Remove dependency |
|
|
102
|
+
| `label_add` | Add label to task |
|
|
103
|
+
| `label_remove` | Remove label |
|
|
104
|
+
|
|
105
|
+
## Available Resources
|
|
106
|
+
|
|
107
|
+
| Resource | URI | Description |
|
|
108
|
+
|----------|-----|-------------|
|
|
109
|
+
| Task List | `trak_flow://tasks` | All tasks |
|
|
110
|
+
| Ready Tasks | `trak_flow://ready` | Tasks with no blockers |
|
|
111
|
+
| Dependencies | `trak_flow://dependencies` | Dependency graph |
|
|
112
|
+
| Plans | `trak_flow://plans` | Plan blueprints |
|
|
113
|
+
| Labels | `trak_flow://labels` | All labels |
|
|
114
|
+
|
|
115
|
+
## Integration Examples
|
|
116
|
+
|
|
117
|
+
### With Claude Desktop
|
|
118
|
+
|
|
119
|
+
Add to your Claude Desktop configuration:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"trak_flow": {
|
|
125
|
+
"command": "tf",
|
|
126
|
+
"args": ["mcp", "start"],
|
|
127
|
+
"cwd": "/path/to/your/project"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### With VS Code
|
|
134
|
+
|
|
135
|
+
If using an MCP-enabled VS Code extension:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcp.servers": {
|
|
140
|
+
"trak_flow": {
|
|
141
|
+
"command": "tf",
|
|
142
|
+
"args": ["mcp", "start"]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### With Ruby LLM
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
require 'ruby_llm'
|
|
152
|
+
require 'ruby_llm/mcp'
|
|
153
|
+
|
|
154
|
+
# Connect to TrakFlow MCP server
|
|
155
|
+
client = RubyLLM::MCP::Client.new(
|
|
156
|
+
transport_type: :stdio,
|
|
157
|
+
command: ["tf", "mcp", "start"],
|
|
158
|
+
working_dir: "/path/to/project"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Use tools
|
|
162
|
+
create_tool = client.tool("task_create")
|
|
163
|
+
result = create_tool.execute(
|
|
164
|
+
title: "New task from AI",
|
|
165
|
+
priority: 1
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Security Considerations
|
|
170
|
+
|
|
171
|
+
### File System Access
|
|
172
|
+
|
|
173
|
+
The MCP server only accesses:
|
|
174
|
+
- `.trak_flow/` directory in the working directory
|
|
175
|
+
- SQLite database file
|
|
176
|
+
- JSONL data file
|
|
177
|
+
|
|
178
|
+
### Authentication
|
|
179
|
+
|
|
180
|
+
Currently, the MCP server does not implement authentication. For production use:
|
|
181
|
+
|
|
182
|
+
1. Run behind a reverse proxy with authentication
|
|
183
|
+
2. Use network-level access controls
|
|
184
|
+
3. Consider implementing custom middleware
|
|
185
|
+
|
|
186
|
+
### Data Privacy
|
|
187
|
+
|
|
188
|
+
- Task data stays local
|
|
189
|
+
- No external API calls
|
|
190
|
+
- No telemetry or analytics
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
Environment variables:
|
|
195
|
+
|
|
196
|
+
| Variable | Description | Default |
|
|
197
|
+
|----------|-------------|---------|
|
|
198
|
+
| `TRAK_FLOW_DIR` | Data directory | `.trak_flow` |
|
|
199
|
+
| `TRAK_FLOW_MCP_PORT` | HTTP port | `9292` |
|
|
200
|
+
| `TRAK_FLOW_MCP_HOST` | HTTP host | `127.0.0.1` |
|
|
201
|
+
|
|
202
|
+
## Next Steps
|
|
203
|
+
|
|
204
|
+
- [Tools Reference](tools.md) - Detailed tool documentation
|
|
205
|
+
- [Resources Reference](resources.md) - Available resources
|
|
206
|
+
- [Integration Guide](integration.md) - Integration examples
|