Skip to content

Commit be1a4e7

Browse files
committed
add mcp
1 parent b67d095 commit be1a4e7

9 files changed

Lines changed: 818 additions & 30 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
with:
2525
extra_plugins: |
2626
@semantic-release/exec
27+
@semantic-release/git
2728
@semantic-release/github
2829
env:
2930
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.opencode/opencode.jsonc‎

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"gh_grep_*": "deny",
88
"kagi_*": "deny",
99
"webfetch": "deny",
10-
"worktree_*": "deny"
10+
"worktree_*": "deny",
1111
},
1212
"agent": {
1313
"researcher": {
@@ -59,22 +59,22 @@
5959
"uniq *": "allow",
6060
"cut *": "allow",
6161
"awk *": "allow",
62-
"tr *": "allow"
63-
}
64-
}
62+
"tr *": "allow",
63+
},
64+
},
6565
},
6666
"scribe": {
6767
"permission": {
6868
"bash": {
69-
"*": "deny"
69+
"*": "deny",
7070
},
7171
"edit": "allow",
7272
"glob": "allow",
7373
"read": "allow",
7474
"write": "allow",
7575
"plan_read": "deny",
76-
"todoread": "deny"
77-
}
76+
"todoread": "deny",
77+
},
7878
},
7979
"coder": {
8080
"permission": {
@@ -88,8 +88,8 @@
8888
"grep": "allow",
8989
"bash": "allow",
9090
"plan_read": "deny",
91-
"todoread": "deny"
92-
}
91+
"todoread": "deny",
92+
},
9393
},
9494
"reviewer": {
9595
"temperature": 0.1,
@@ -102,35 +102,35 @@
102102
"git log*": "allow",
103103
"git show*": "allow",
104104
"git blame*": "allow",
105-
"rg *": "allow"
105+
"rg *": "allow",
106106
},
107107
"plan_read": "allow",
108108
"delegation_read": "allow",
109-
"delegation_list": "allow"
110-
}
109+
"delegation_list": "allow",
110+
},
111111
},
112112
"plan": {
113113
"permission": {
114114
"edit": "deny",
115115
"write": "deny",
116116
"bash": {
117-
"*": "deny"
117+
"*": "deny",
118118
},
119119
"task": "allow",
120-
"worktree_*": "allow"
121-
}
120+
"worktree_*": "allow",
121+
},
122122
},
123123
"build": {
124124
"prompt": "You are a **build orchestrator**. You coordinate implementation through delegation - you do NOT implement directly.\\\\\\\\n\\\\\\\\n## Your Role\\\\\\\\n- Delegate implementation to `coder`\\\\\\\\n- Delegate documentation to `scribe`\\\\\\\\n- Delegate codebase analysis to `explore`\\\\\\\\n- Delegate external research to `researcher`\\\\\\\\n- Interpret results and decide next steps\\\\\\\\n\\\\\\\\n## Critical Constraint\\\\\\\\nYou CANNOT edit files or run commands directly. For ALL implementation and verification, delegate to `coder`.",
125125
"permission": {
126126
"edit": "deny",
127127
"write": "deny",
128128
"bash": {
129-
"*": "deny"
129+
"*": "deny",
130130
},
131131
"task": "allow",
132-
"worktree_*": "allow"
133-
}
132+
"worktree_*": "allow",
133+
},
134134
},
135135
"explore": {
136136
"permission": {
@@ -163,34 +163,45 @@
163163
"hostname": "allow",
164164
"whoami": "allow",
165165
"which *": "allow",
166-
"realpath *": "allow"
167-
}
168-
}
169-
}
166+
"realpath *": "allow",
167+
},
168+
},
169+
},
170170
},
171171
"mcp": {
172172
"context7": {
173173
"type": "remote",
174174
"url": "https://mcp.context7.com/mcp",
175-
"enabled": true
175+
"enabled": true,
176176
},
177177
"exa": {
178178
"type": "remote",
179179
"url": "https://mcp.exa.ai/mcp",
180-
"enabled": true
180+
"enabled": true,
181181
},
182182
"gh_grep": {
183183
"type": "remote",
184184
"url": "https://mcp.grep.app",
185-
"enabled": true
186-
}
185+
"enabled": true,
186+
},
187+
"ocv": {
188+
"type": "local",
189+
"command": [
190+
"deno",
191+
"run",
192+
"-A",
193+
"main.ts",
194+
"mcp"
195+
],
196+
"enabled": true,
197+
},
187198
},
188199
"instructions": [
189200
"./tools/philosophy.md"
190201
],
191202
"plugin": [
192203
"@tarquinen/opencode-dcp@3.1.3",
193-
"@franlol/opencode-md-table-formatter@0.0.6"
194-
]
204+
"@franlol/opencode-md-table-formatter@0.0.6",
205+
],
195206
// Add MCP servers, tools, plugins here
196207
}

‎.releaserc.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
["@semantic-release/exec", {
77
"prepareCmd": "echo \"export const VERSION = '${nextRelease.version}';\" > version.ts"
88
}],
9+
["@semantic-release/git", {
10+
"assets": ["version.ts"]
11+
}],
912
["@semantic-release/github"]
1013
]
1114
}

‎README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ ocv sessions <path> # List sessions matching directory path
7575
ocv session <id> # Detailed info for a specific session
7676
ocv search <query> # Search sessions by title or directory
7777
ocv rename --from-dir <old-dir> -d <new-dir> # Batch-rename session directory
78+
ocv mcp # MCP stdio server for AI agent integration
7879
ocv --help # Top-level help
7980
ocv <command> --help # Per-command help
8081
ocv --version # Show version
@@ -91,6 +92,7 @@ ocv dash --output json # Dashboard data as JSON
9192
ocv overview --output json # Overview as JSON
9293
ocv search <query> --output json # Search results as JSON
9394
ocv rename --from-dir ... -d ... --output json # Rename result as JSON
95+
ocv mcp # MCP server — communicates via JSON-RPC on stdio (no --output flag)
9496
```
9597

9698
### Excluding directories
@@ -128,6 +130,33 @@ The `sessions` and `search` commands show a "Type" column:
128130
- **Main** — top-level session (no parent)
129131
- **Sub** — subagent/delegated session (has a parent_id)
130132

133+
### MCP server
134+
135+
`ocv` includes a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) stdio server for AI agent tool access. Run `ocv mcp` to start the server — it communicates over stdin/stdout via JSON-RPC, exposing database queries as structured, typed tools.
136+
137+
**Available tools:** `get_stats`, `get_overview`, `list_sessions`, `get_session`, `search_sessions`, `get_top_models`, `get_top_providers`, `get_weekly_activity`
138+
139+
Register with OpenCode by adding to `.opencode/opencode.jsonc` in any project:
140+
141+
```json
142+
"ocv": {
143+
"type": "local",
144+
"command": ["ocv", "mcp"],
145+
"enabled": true
146+
}
147+
```
148+
149+
Or from source (requires Deno):
150+
```json
151+
"ocv": {
152+
"type": "local",
153+
"command": ["deno", "run", "-A", "main.ts", "mcp"],
154+
"enabled": true
155+
}
156+
```
157+
158+
Agents in that workspace can then query session data, token usage, costs, and more through structured tool calls.
159+
131160
## Commands
132161

133162
| Command | Description |
@@ -139,6 +168,7 @@ The `sessions` and `search` commands show a "Type" column:
139168
| `session <id>` | Single session detail with messages and todo breakdown |
140169
| `search <query>` | Full-text search over session titles and directories |
141170
| `rename --from-dir <old> -d <new>` | Batch-rename session directory and path fields when project moves |
171+
| `mcp` | Start MCP stdio server — exposes DB queries as structured tools for AI agents |
142172

143173
## Semantic versioning
144174

‎deno.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.7",
2020
"@cliffy/table": "jsr:@cliffy/table@^1.0.0-rc.7",
2121
"@db/sqlite": "jsr:@db/sqlite@^0.12.0",
22+
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.9.0",
2223
"@std/path": "jsr:@std/path@^1.0.0"
2324
}
2425
}

0 commit comments

Comments
 (0)