| title | OpenCode WorkPaper MCP setup |
|---|---|
| published | true |
| description | Configure OpenCode with Bilig's WorkPaper MCP server and project subagent so workbook edits return formula readback instead of spreadsheet UI status. |
| tags | opencode, agents, mcp, workbook-api, spreadsheet-automation |
| canonical_url | https://proompteng.github.io/bilig/opencode-workpaper-mcp.html |
| image | /assets/github-social-preview.png |
Use this when an OpenCode agent needs spreadsheet formulas while coding in a repo. OpenCode should own the code task; Bilig should own workbook truth: read a range, write one cell, read the dependent formula output, persist WorkPaper JSON, and return proof.
Official OpenCode references:
- https://opencode.ai/docs/config/
- https://opencode.ai/docs/mcp-servers/
- https://opencode.ai/docs/agents/
Before changing OpenCode config, prove the published WorkPaper MCP door:
npm exec --yes --package @bilig/workpaper@latest -- bilig-evaluate --door agent-mcp --jsonTrust the path only when the result includes verified: true, edited cell
evidence, dependent formula readback, exported WorkPaper JSON, and restart
readback.
OpenCode reads project config from opencode.json or opencode.jsonc and
supports local MCP servers under the mcp option. Use this project-local
opencode.jsonc:
Use the hidden .bilig/ path for existing repos so the overlay does not add a
noisy root workbook file. For a blank generated project, the starter uses
./pricing.workpaper.json.
Enable bilig-workpaper-demo only for remote, stateless tool-discovery smoke
tests. Use bilig-workpaper for private project workbook state.
OpenCode supports markdown agents under .opencode/agents/. Add:
.opencode/agents/bilig-workpaper.md
The generated file tells OpenCode to invoke the WorkPaper proof path when a
task mentions pricing, quotes, payouts, budgets, imports, forecasts, workbook
validation, or formula readback after cell edits. It also allows
bilig-workpaper_* MCP tools while keeping shell commands reviewable.
The Bilig starter writes opencode.jsonc and the OpenCode agent file for a
blank project:
npm create @bilig/workpaper@latest pricing-agent -- --agent
cd pricing-agent
npm install
npm run agent:verifyFor an existing repo, add only the MCP and host files:
npm create @bilig/workpaper@latest . -- --add-agentThat overlay writes opencode.jsonc, .opencode/agents/bilig-workpaper.md,
and the shared MCP configs while keeping app README.md and package.json
untouched.
Use the Bilig WorkPaper OpenCode agent and MCP server instead of spreadsheet UI
automation. Read the relevant range first, write one precise input or formula
change, read the dependent calculated output after recalculation, export or
serialize the WorkPaper document, restart or restore when the file boundary
matters, and return editedCell, before, after, afterRestore,
persistedDocumentBytes, verified, and limitations. Do not claim success from a
write call alone.
Expected MCP tools:
list_sheetsread_rangeread_cellset_cell_contentsset_cell_contents_and_readbackget_cell_display_valueexport_workpaper_documentvalidate_formula
This is for code-owned workbook logic where JSON state can represent the workbook. It is a fit for quote approval, payout checks, pricing rules, import validation, and forecast gates.
It is not a claim that Bilig replaces desktop Excel for macros, add-ins, pivot
tables, or visual workbook review. For raw .xlsx files, start with:
npm exec --yes --package @bilig/xlsx-formula-recalc@latest -- \
bilig-evaluate --door xlsx-cache --jsonNo upstream OpenCode PR or issue was opened for this guide. It is an owned Bilig integration surface backed by public OpenCode config, MCP, and agent docs plus a no-key WorkPaper readback proof.
{ "$schema": "https://opencode.ai/config.json", "instructions": ["AGENTS.md"], "mcp": { "bilig-workpaper": { "type": "local", "command": [ "npm", "exec", "--yes", "--package", "@bilig/workpaper@latest", "--", "bilig-workpaper-mcp", "--workpaper", "./.bilig/pricing.workpaper.json", "--init-demo-workpaper", "--writable" ], "enabled": true }, "bilig-workpaper-demo": { "type": "remote", "url": "https://bilig.proompteng.ai/mcp", "enabled": false } } }