11# opencode-palantir
22
3- OpenCode plugin that provides ** Palantir Foundry documentation** to AI agents via a local Parquet
4- database.
3+ [ ![ npm] ( https://img.shields.io/npm/v/@openontology/opencode-palantir?logo=npm&label=npm )] ( https://www.npmjs.com/package/@openontology/opencode-palantir )
4+ [ ![ downloads] ( https://img.shields.io/npm/dm/@openontology/opencode-palantir?logo=npm&label=downloads )] ( https://www.npmjs.com/package/@openontology/opencode-palantir )
5+ ![ CI] ( https://img.shields.io/github/actions/workflow/status/anand-testcompare/opencode-palantir/pr.yml?branch=main&label=CI&logo=github )
6+ ![ bun] ( https://img.shields.io/badge/bun-1.3.2-000000?logo=bun&logoColor=white )
7+ ![ @opencode-ai/plugin ] ( https://img.shields.io/github/package-json/dependency-version/anand-testcompare/opencode-palantir/dev/%40opencode-ai%2Fplugin?label=opencode%20plugin%20api&logo=npm )
8+ ![ palantir-mcp] ( https://img.shields.io/npm/v/palantir-mcp?logo=npm&label=palantir-mcp )
9+ ![ hyparquet] ( https://img.shields.io/github/package-json/dependency-version/anand-testcompare/opencode-palantir/hyparquet?label=hyparquet&logo=npm )
510
6- ## Features
11+ OpenCode plugin that provides:
712
8- - Fetches all ~ 3,600 pages from Palantir's public documentation
9- - Stores in a local Parquet file for fast offline access (~ 17MB)
10- - Exposes ` get_doc_page ` and ` list_all_docs ` tools for AI agents
13+ - Palantir public documentation tools backed by a local Parquet database
14+ - Foundry MCP bootstrapping helpers (commands, agents, and optional auto-bootstrap)
1115
12- ## Quick start (OpenCode users)
16+ NPM package: https://www.npmjs.com/package/@openontology/opencode-palantir
1317
14- ### 1) Enable the plugin in ` opencode.json ` / ` opencode.jsonc `
18+ ## Supported OS
1519
16- Add the plugin to your OpenCode config:
20+ - Supported: macOS, Linux
21+ - Windows: not supported (WSL2 might work, but we don’t debug Windows-specific issues)
22+
23+ ## Install (OpenCode)
24+
25+ Add the plugin in your OpenCode config (` opencode.jsonc ` ):
1726
1827``` jsonc
1928{
2029 " $schema" : " https://opencode.ai/config.json" ,
21- " plugin" : [" @openontology/opencode-palantir@^0.1.1 " ]
30+ " plugin" : [" @openontology/opencode-palantir@^0.1.4 " ]
2231}
2332```
2433
2534Restart OpenCode.
2635
27- ### 2) (Optional) Install per-project
36+ After enabling the plugin, OpenCode will automatically register:
37+
38+ - Tools: ` get_doc_page ` , ` list_all_docs `
39+ - Commands: ` /refresh-docs ` , ` /setup-palantir-mcp ` , ` /rescan-palantir-mcp-tools `
40+ - Agents: ` foundry-librarian ` , ` foundry `
41+
42+ ### Versions: how to get the latest
43+
44+ Prefer ** pinned** or ** semver range** installs (like ` @^0.1.4 ` ), and update intentionally.
45+
46+ Avoid using ` @latest ` in config:
47+
48+ - it can make startup slower (npm resolution/install on startup)
49+ - it makes behavior less deterministic
50+ - depending on caching, you may not get the upgrade behavior you expect
51+
52+ To find the newest version and changelog:
53+
54+ - NPM versions: https://www.npmjs.com/package/@openontology/opencode-palantir
55+ - GitHub releases: https://github.com/anand-testcompare/opencode-palantir/releases
56+ - Repo changelog: ` CHANGELOG.md `
57+
58+ ### (Optional) Install per-project
2859
2960In your project repo, add the plugin as a dependency inside ` .opencode/ ` (keeps plugin deps separate
3061from your app deps):
@@ -35,7 +66,7 @@ mkdir -p .opencode
3566cat > .opencode/package.json << 'EOF '
3667{
3768 "dependencies": {
38- "@openontology/opencode-palantir": "^0.1.1 "
69+ "@openontology/opencode-palantir": "^0.1.4 "
3970 }
4071}
4172EOF
4576
4677Then create a tiny wrapper file in ` .opencode/plugins/ ` :
4778
48- Create a tiny wrapper file in ` .opencode/plugins/ ` :
49-
5079``` bash
5180mkdir -p .opencode/plugins
5281
5988
6089OpenCode automatically loads ` .js ` /` .ts ` files from ` .opencode/plugins/ ` at startup.
6190
62- > If your OpenCode setup uses an ` opencode.json ` / ` opencode.jsonc ` that restricts plugin loading,
63- > make sure ` .opencode/plugins/ ` (or the specific plugin file) is included.
91+ ## Environment variables (Foundry MCP)
92+
93+ This plugin never writes secrets to disk. In ` opencode.jsonc ` , the token is always referenced as
94+ ` {env:FOUNDRY_TOKEN} ` .
95+
96+ ### Variables
97+
98+ - ` FOUNDRY_URL `
99+ - Foundry base URL (used for auto-bootstrap and can be used as a default for ` /setup-palantir-mcp ` )
100+ - Example: ` https://YOUR-STACK.palantirfoundry.com `
101+ - ` FOUNDRY_TOKEN `
102+ - Foundry token used by ` palantir-mcp ` for tool discovery
103+ - Must be exported (not just set in a shell)
104+
105+ ### Recommended setup (zsh, macOS/Linux)
106+
107+ Use your existing shell secrets file. For example, if you already source ` ~/.shell_secrets ` from
108+ ` ~/.zshrc ` , add:
109+
110+ ``` zsh
111+ export FOUNDRY_URL=' https://YOUR-STACK.palantirfoundry.com'
112+ export FOUNDRY_TOKEN=' YOUR_TOKEN'
113+ ```
114+
115+ Lock it down:
116+
117+ ``` bash
118+ chmod 600 ~ /.shell_secrets
119+ ```
120+
121+ Ensure ` ~/.zshrc ` sources it:
122+
123+ ``` zsh
124+ if [ -f " $HOME /.shell_secrets" ]; then
125+ source " $HOME /.shell_secrets"
126+ fi
127+ ```
128+
129+ If you still see “token not exported” errors, verify ` echo $FOUNDRY_TOKEN ` prints a value and that
130+ it’s ` export ` ed in the environment where OpenCode is launched.
131+
132+ ## Docs tools (Palantir public docs)
64133
65- ### 3) Get ` docs.parquet `
134+ This package does ** not ** ship with docs bundled. The docs DB is a local file:
66135
67- This package does ** not ** ship with docs bundled. You have two options:
136+ - ` data/ docs.parquet ` (in your repo root)
68137
69- #### Option A (recommended): fetch inside OpenCode
138+ ### Fetch docs
70139
71140In OpenCode, run:
72141
73142- ` /refresh-docs `
74143
75- This downloads the docs and writes them to ` data/docs.parquet ` in your project root .
144+ This downloads the docs and writes ` data/docs.parquet ` .
76145
77- #### Option B: download a prebuilt Parquet file
146+ ### Tools
78147
79- Download ` data/docs.parquet ` from this GitHub repo and place it at:
148+ - ` get_doc_page `
149+ - Retrieve a doc page by URL, or fuzzy match by query
150+ - ` list_all_docs `
151+ - List docs with pagination and optional query/scope filtering
80152
81- - ` <your-project>/ data/docs.parquet`
153+ If ` data/docs.parquet ` is missing, both tools will tell you to run ` /refresh-docs ` .
82154
83- ## Using the tools
155+ ## Foundry MCP helpers
84156
85- When installed, this plugin exposes:
157+ This plugin registers Foundry commands and agents automatically at startup (config-driven).
86158
87- - ** ` get_doc_page ` ** - Retrieve a specific doc page by URL
88- - ** ` list_all_docs ` ** - List all available documentation pages
159+ ### Auto-bootstrap (no command required)
89160
90- If ` data/docs.parquet ` is missing, both tools will instruct you to run ` /refresh-docs ` .
161+ If you set both ` FOUNDRY_TOKEN ` and ` FOUNDRY_URL ` , the plugin will automatically and idempotently
162+ patch repo-root ` opencode.jsonc ` to initialize:
91163
92- ## Foundry MCP setup helpers
164+ - ` mcp.palantir-mcp ` local server config
165+ - global tool deny: ` tools.palantir-mcp_* = false `
166+ - per-agent allow/deny toggles under ` foundry-librarian ` and ` foundry `
93167
94- This plugin also provides two OpenCode commands to set up ` palantir-mcp ` with project-scoped tool
95- gating and Foundry sub-agents:
168+ ### Guided setup and maintenance
96169
97- - ** ` /setup-palantir-mcp <foundry_api_url> ` **
170+ - ` /setup-palantir-mcp <foundry_api_url> `
98171 - Creates/patches repo-root ` opencode.jsonc `
99172 - Adds ` mcp.palantir-mcp ` (if missing) as a local ` npx palantir-mcp --foundry-api-url ... ` server
100173 - Enforces global deny: ` tools.palantir-mcp_* = false `
101174 - Creates ` foundry-librarian ` and ` foundry ` agents
102- - Dynamically discovers the current ` palantir-mcp ` tool list and writes explicit ` true/false `
103- per-tool toggles under each Foundry agent
104- - ** ` /rescan-palantir-mcp-tools ` **
105- - Re-discovers the ` palantir-mcp ` tool list and adds any missing explicit toggles
175+ - Discovers ` palantir-mcp ` tools and writes explicit ` true/false ` toggles under each agent
176+ - ` /rescan-palantir-mcp-tools `
177+ - Re-discovers the ` palantir-mcp ` tool list and adds missing explicit toggles
106178 - Never overwrites existing ` palantir-mcp_* ` toggles
107179
108- Auth is always env-only. The token is referenced as ` {env:FOUNDRY_TOKEN} ` and is never written to
109- disk.
180+ ### About palantir-mcp versions (important)
181+
182+ The generated MCP server uses ` npx -y palantir-mcp ... ` by default.
183+
184+ Notes:
185+
186+ - First run can be slow (npx may need to download/install).
187+ - ` @latest ` / unpinned installs are less deterministic.
188+
189+ Recommendation: once you’re set up, pin the version in ` opencode.jsonc ` :
190+
191+ ``` jsonc
192+ {
193+ " mcp" : {
194+ " palantir-mcp" : {
195+ " type" : " local" ,
196+ " command" : [
197+ " npx" ,
198+ " -y" ,
199+ " palantir-mcp@<version>" ,
200+ " --foundry-api-url" ,
201+ " https://YOUR-STACK.palantirfoundry.com"
202+ ]
203+ }
204+ }
205+ }
206+ ```
207+
208+ ## Development (this repo)
209+
210+ ### Setup
211+
212+ ``` bash
213+ mise run setup
214+ ```
215+
216+ ### Common tasks
217+
218+ - Build: ` mise run build `
219+ - Test: ` mise run test `
220+ - Lint: ` mise run lint `
221+ - Typecheck: ` mise run typecheck `
222+ - Format: ` mise run format `
110223
111- ## Setup (this repo)
224+ ### Smoke test the built artifact
112225
113226``` bash
114- bun install
227+ mise run smoke
115228```
116229
117- ## Fetching Documentation
230+ ### Fetch docs parquet (local dev)
118231
119232Fetch all Palantir docs into ` data/docs.parquet ` (~ 2 minutes, ~ 17MB file):
120233
121234``` bash
122235bun run src/docs/fetch-cli.ts
123236```
124237
125- ## Querying the Data
126-
127- ### Schema
238+ ### Parquet schema (local dev)
128239
129240The Parquet file contains a single row group with the following columns:
130241
@@ -137,7 +248,7 @@ The Parquet file contains a single row group with the following columns:
137248| ` meta ` | string | JSON-encoded metadata |
138249| ` fetched_at ` | string | ISO 8601 timestamp of when fetched |
139250
140- ### Bun
251+ Example ( Bun):
141252
142253``` typescript
143254import { parquetReadObjects } from ' hyparquet' ;
@@ -147,76 +258,6 @@ const file = await Bun.file('data/docs.parquet').arrayBuffer();
147258// List all pages (url + title only)
148259const pages = await parquetReadObjects ({ file , columns: [' url' , ' title' ] });
149260console .log (` ${pages .length } pages ` );
150-
151- // Search by title
152- const matches = pages .filter ((p ) => p .title .includes (' Pipeline' ));
153- console .log (matches .slice (0 , 10 ));
154-
155- // Get a specific page's content by row index
156- const urlToRow = new Map (pages .map ((p , i ) => [p .url , i ]));
157- const rowIndex = urlToRow .get (' /foundry/ontology/overview/' );
158- if (rowIndex !== undefined ) {
159- const [page] = await parquetReadObjects ({
160- file ,
161- rowStart: rowIndex ,
162- rowEnd: rowIndex + 1 ,
163- });
164- console .log (page .content );
165- }
166- ```
167-
168- ## OpenCode Tools
169-
170- When installed as an OpenCode plugin, exposes:
171-
172- - ** ` get_doc_page ` ** - Retrieve a specific doc page by URL
173- - ** ` list_all_docs ` ** - List all available documentation pages
174- - ** ` /refresh-docs ` ** - Command hook to re-fetch all documentation
175-
176- ### Installing in OpenCode (this repo only)
177-
178- For local development against ` dist/ ` , you can point the wrapper at the built artifact:
179-
180- ``` bash
181- mkdir -p .opencode/plugins
182-
183- cat > .opencode/plugins/opencode-palantir.js << 'EOF '
184- import plugin from '../../dist/index.js';
185-
186- export default plugin;
187- EOF
188- ```
189-
190- ## Development
191-
192- Build the plugin:
193-
194- ``` bash
195- mise run build
196- ```
197-
198- Run tests:
199-
200- ``` bash
201- mise run test
202- ```
203-
204- Smoke test the built artifact (build + verify tools load from ` dist/index.js ` ):
205-
206- ``` bash
207- mise run smoke
208- ```
209-
210- Lint code:
211-
212- ``` bash
213- mise run lint
214- ```
215-
216- Format with Prettier:
217-
218- ``` bash
219- mise run format
220261```
221262
222263## Release notes
0 commit comments