openuispec 0.1.38 → 0.1.39
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.
- package/README.md +7 -0
- package/cli/init.ts +34 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -265,6 +265,13 @@ OpenUISpec includes an MCP (Model Context Protocol) server that exposes CLI comm
|
|
|
265
265
|
}
|
|
266
266
|
```
|
|
267
267
|
|
|
268
|
+
**Codex** (`.codex/config.toml`):
|
|
269
|
+
```toml
|
|
270
|
+
[mcp_servers.openuispec]
|
|
271
|
+
command = "openuispec"
|
|
272
|
+
args = ["mcp"]
|
|
273
|
+
```
|
|
274
|
+
|
|
268
275
|
Or run directly: `openuispec mcp`
|
|
269
276
|
|
|
270
277
|
Set `OPENUISPEC_PROJECT_DIR` to override the working directory.
|
package/cli/init.ts
CHANGED
|
@@ -489,13 +489,42 @@ const EXPECTED_MCP_CONFIG = {
|
|
|
489
489
|
*
|
|
490
490
|
* All use the same { mcpServers: { openuispec: { command, args } } } shape.
|
|
491
491
|
*/
|
|
492
|
-
const
|
|
492
|
+
const JSON_MCP_PATHS = [
|
|
493
493
|
".mcp.json",
|
|
494
494
|
join(".vscode", "mcp.json"),
|
|
495
495
|
];
|
|
496
496
|
|
|
497
|
+
/** Codex uses TOML: .codex/config.toml */
|
|
498
|
+
const CODEX_CONFIG_PATH = join(".codex", "config.toml");
|
|
499
|
+
const CODEX_MCP_BLOCK = `\n[mcp_servers.openuispec]\ncommand = "openuispec"\nargs = ["mcp"]\n`;
|
|
500
|
+
|
|
501
|
+
function configureCodexMcp(cwd: string, quiet: boolean): void {
|
|
502
|
+
const codexDir = join(cwd, ".codex");
|
|
503
|
+
if (!existsSync(codexDir)) return;
|
|
504
|
+
|
|
505
|
+
const configPath = join(codexDir, "config.toml");
|
|
506
|
+
try {
|
|
507
|
+
let content = "";
|
|
508
|
+
try {
|
|
509
|
+
content = readFileSync(configPath, "utf-8");
|
|
510
|
+
} catch {
|
|
511
|
+
// file doesn't exist — will create
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (content.includes("[mcp_servers.openuispec]")) {
|
|
515
|
+
if (!quiet) console.log(` skip ${CODEX_CONFIG_PATH} (openuispec MCP already configured)`);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
writeFileSync(configPath, content + CODEX_MCP_BLOCK);
|
|
520
|
+
if (!quiet) console.log(` ${content ? "update" : "create"} ${CODEX_CONFIG_PATH} (MCP server configured)`);
|
|
521
|
+
} catch {
|
|
522
|
+
if (!quiet) console.log(` skip ${CODEX_CONFIG_PATH} (could not configure MCP server)`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
497
526
|
function configureMcp(cwd: string, showRestart: boolean, quiet: boolean = false): void {
|
|
498
|
-
for (const relPath of
|
|
527
|
+
for (const relPath of JSON_MCP_PATHS) {
|
|
499
528
|
const configPath = join(cwd, relPath);
|
|
500
529
|
|
|
501
530
|
// .vscode/mcp.json: only write if .vscode/ already exists
|
|
@@ -529,6 +558,9 @@ function configureMcp(cwd: string, showRestart: boolean, quiet: boolean = false)
|
|
|
529
558
|
}
|
|
530
559
|
}
|
|
531
560
|
|
|
561
|
+
// Codex: .codex/config.toml (TOML format)
|
|
562
|
+
configureCodexMcp(cwd, quiet);
|
|
563
|
+
|
|
532
564
|
if (showRestart) console.log(`\n Restart your AI coding agent to activate the MCP server.`);
|
|
533
565
|
|
|
534
566
|
// Clean up stale .claude.json MCP config from older versions
|