@orygn/opa-mcp 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -5,7 +5,7 @@ All notable changes to `@orygn/opa-mcp` are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- The public surface for the purposes of SemVer is:
8
+ The public surface, for the purposes of SemVer, is:
9
9
 
10
10
  - the set of registered MCP tools, prompts, and resources
11
11
  - the input and output schemas of those tools
@@ -17,67 +17,117 @@ not part of the public surface and may change in minor releases.
17
17
 
18
18
  ## [Unreleased]
19
19
 
20
- ## [0.1.0] initial public release
20
+ ## [0.1.1] - 2026-05-09
21
+
22
+ ### Fixed
23
+
24
+ - `rego_lint` no longer fires `directory-package-mismatch` as a false
25
+ positive on inline `source`. The rule's verdict depends on the
26
+ on-disk path, but inline source is written to a randomized temp file
27
+ whose path can never match the source's declared package, so the rule
28
+ was guaranteed to fire. It is now auto-disabled when `source` is
29
+ used. Re-enable via the `enable` parameter if your workflow actually
30
+ needs it.
31
+ - `rego_lint` violation locations no longer leak the temp-file path on
32
+ inline source. `location.file` is reported as `<inline>` for
33
+ inline-source calls; row and column are preserved.
34
+
35
+ ### Added
36
+
37
+ - Startup self-check probes the configured `opa` and `regal` binaries
38
+ in the background and writes a warning entry to the log file when
39
+ either is unreachable, with an install-hint pointing at the
40
+ `OPA_BINARY` and `REGAL_BINARY` environment variables. The check is
41
+ fire-and-forget and does not delay the MCP `initialize` handshake.
42
+ Most often hit under Claude Desktop, which spawns MCP servers with a
43
+ reduced PATH on macOS and Windows.
44
+ - `mcpName: "io.github.OrygnsCode/opa-mcp"` in `package.json`. This is
45
+ the npm-side ownership marker the official MCP Registry requires
46
+ before it accepts a published package; it was missing in 0.1.0.
47
+
48
+ ### Changed
49
+
50
+ - README architecture diagram switched from Unicode box-drawing
51
+ characters to plain ASCII (`+`, `-`, `|`) so it renders uniformly on
52
+ npm's web UI; the previous Unicode corners showed visible gaps in
53
+ npm's font.
54
+
55
+ ### Security
56
+
57
+ - Pinned the transitive `hono` dependency to `>= 4.12.18` via a
58
+ `package.json` `overrides` block. This clears three advisories
59
+ (GHSA series for JSX SSR style injection, JWT NumericDate
60
+ validation, and Vary-header handling in cache middleware) reported
61
+ against the version pulled by `@modelcontextprotocol/sdk`. None of
62
+ the affected code paths execute in this server (we run stdio only,
63
+ not the HTTP transport that uses hono), but pinning eliminates the
64
+ `npm audit` noise on user installs.
65
+
66
+ ### Distribution
67
+
68
+ - Listed on the official MCP Registry at
69
+ `io.github.OrygnsCode/opa-mcp`.
70
+
71
+ ## [0.1.0] - initial public release
21
72
 
22
73
  ### Added
23
74
 
24
75
  #### Tools (32)
25
76
 
26
- **Authoring (7)** `rego_format`, `rego_check`, `rego_lint`,
77
+ **Authoring (7).** `rego_format`, `rego_check`, `rego_lint`,
27
78
  `rego_parse_ast`, `rego_inspect`, `rego_capabilities`, `rego_deps`.
28
79
  Operate on Rego source without a running OPA server.
29
80
 
30
- **Evaluation (7)** `rego_eval` plus `_with_explain`, `_with_profile`,
81
+ **Evaluation (7).** `rego_eval` plus `_with_explain`, `_with_profile`,
31
82
  `_with_coverage` variants; `rego_test`, `rego_bench`,
32
83
  `rego_compile_query`. Run policies against inputs with optional
33
84
  trace, profile, and coverage.
34
85
 
35
- **Bundles (2)** `opa_bundle_build`, `opa_bundle_sign`. Build and
86
+ **Bundles (2).** `opa_bundle_build`, `opa_bundle_sign`. Build and
36
87
  sign deployable bundles.
37
88
 
38
- **Server management (12)** `opa_list_policies`, `opa_get_policy`,
89
+ **Server management (12).** `opa_list_policies`, `opa_get_policy`,
39
90
  `opa_put_policy`, `opa_delete_policy`, `opa_get_data`, `opa_put_data`,
40
91
  `opa_patch_data`, `opa_query_decision`, `opa_compile_query`,
41
92
  `opa_health`, `opa_status`, `opa_config`. Manage a running OPA over
42
93
  its REST API.
43
94
 
44
- **Helpers (4)** `rego_explain_decision` produces a structured
95
+ **Helpers (4).** `rego_explain_decision` produces a structured
45
96
  trace and per-rule fired/not-fired summary; `rego_generate_test_skeleton`
46
97
  emits a `*_test.rego` stub from a policy AST; `rego_describe_policy`
47
- returns a structured summary of package / imports / rules;
98
+ returns a structured summary of package, imports, and rules;
48
99
  `rego_suggest_fix` maps known diagnostic codes to mechanical fix
49
100
  suggestions.
50
101
 
51
102
  #### Prompts (3)
52
103
 
53
104
  `policy_authoring_assistant`, `policy_review_checklist`,
54
- `decision_debugging_workflow` workflow templates that direct the
105
+ `decision_debugging_workflow`. Workflow templates that direct the
55
106
  agent through writing, reviewing, or debugging a policy using the
56
107
  tools above.
57
108
 
58
109
  #### Resources (3)
59
110
 
60
- `opa://builtins` categorized OPA builtin function reference,
111
+ `opa://builtins`. Categorized OPA builtin function reference,
61
112
  derived at read time from `opa capabilities --current` and annotated
62
113
  with security-sensitive functions.
63
114
 
64
- `opa://style-guide` condensed Rego style guide covering
115
+ `opa://style-guide`. Condensed Rego style guide covering
65
116
  `rego.v1`, package layout, naming, default-deny, comprehensions vs
66
117
  `every`, schema annotations, and tests.
67
118
 
68
- `opa://patterns` curated pattern library with six worked
119
+ `opa://patterns`. Curated pattern library with six worked
69
120
  examples: RBAC, ABAC, Kubernetes admission, Terraform IaC gates, API
70
121
  authorization, rate limiting. Each pattern includes a working policy,
71
122
  a test, and common pitfalls.
72
123
 
73
124
  #### Distribution
74
125
 
75
- - npm package `@orygn/opa-mcp`
126
+ - npm package `@orygn/opa-mcp`.
76
127
  - Multi-arch Docker image `orygn/opa-mcp` bundling pinned `opa`
77
- 0.69.0 and `regal` 0.30.0 binaries
78
- - MCPB bundle (`opa-mcp.mcpb`) attached to GitHub releases
79
- - MCP registry entry under `io.github.orygnscode/opa-mcp`
80
- - Smithery descriptor for one-click client installs
128
+ 0.69.0 and `regal` 0.30.0 binaries.
129
+ - MCPB bundle (`opa-mcp.mcpb`) attached to GitHub releases.
130
+ - Smithery descriptor for one-click client installs.
81
131
 
82
132
  #### Configuration
83
133
 
@@ -91,9 +141,10 @@ fail-secure when `OPA_MCP_ALLOWED_PATHS` is unset.
91
141
 
92
142
  50 unit tests (mocked subprocess) plus 20 integration tests
93
143
  (real `opa` 0.69.0 and `regal` 0.30.0 binaries) covering both CLI
94
- wrappers end-to-end. CI matrix: Ubuntu / macOS / Windows on Node 20
95
- and 22, plus CodeQL security scanning and weekly Dependabot updates
144
+ wrappers end-to-end. CI matrix: Ubuntu, macOS, and Windows on Node
145
+ 20 and 22, plus CodeQL security scanning and weekly Dependabot updates
96
146
  for npm, GitHub Actions, and Docker base images.
97
147
 
98
- [Unreleased]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.0...HEAD
148
+ [Unreleased]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.1...HEAD
149
+ [0.1.1]: https://github.com/OrygnsCode/opa-mcp-server/releases/tag/v0.1.1
99
150
  [0.1.0]: https://github.com/OrygnsCode/opa-mcp-server/releases/tag/v0.1.0
package/README.md CHANGED
@@ -14,15 +14,15 @@ VS Code, Windsurf, Zed, and others) into a first-class
14
14
  environment.
15
15
 
16
16
  ```
17
- ┌────────────────────┐ MCP / stdio ┌─────────────────┐ spawn / HTTP ┌──────────────────┐
18
- Claude · Cursor · ────────────▶ @orygn/opa-mcp ─────────────▶ opa · regal ·
19
- VS Code · ... ◀──────────── ◀───────────── OPA REST API
20
- └────────────────────┘ 32 tools └─────────────────┘ └──────────────────┘
17
+ +--------------------+ MCP / stdio +-----------------+ spawn / HTTP +------------------+
18
+ | Claude · Cursor · | ------------> | @orygn/opa-mcp | -------------> | opa · regal · |
19
+ | VS Code · ... | <------------ | | <------------- | OPA REST API |
20
+ +--------------------+ 32 tools +-----------------+ +------------------+
21
21
  ```
22
22
 
23
- > **Status:** v0.1.0. First stable release. Tool surface, error codes, and
24
- > environment variables follow [SemVer](https://semver.org/) from this
25
- > version forward.
23
+ > **Status:** v0.1.1. Tool surface, error codes, and
24
+ > environment variables follow [SemVer](https://semver.org/) from
25
+ > v0.1.0 forward.
26
26
 
27
27
  ---
28
28
 
@@ -1,5 +1,13 @@
1
1
  import type { Config } from '../config.js';
2
2
  import { type SpawnResult } from './subprocess.js';
3
+ /**
4
+ * Rules whose verdict depends on the on-disk path of the file being
5
+ * linted. When a caller passes inline `source`, the file lives at a
6
+ * randomized temp path that can never match the source's declared
7
+ * package, so these rules always fire as false positives. Auto-disabled
8
+ * for inline source unless the caller explicitly re-enables them.
9
+ */
10
+ export declare const INLINE_SOURCE_FALSE_POSITIVE_RULES: readonly ["directory-package-mismatch"];
3
11
  /** Input for `regal lint`. */
4
12
  export interface LintInput {
5
13
  /** Inline Rego source. Mutually exclusive with `paths`. */
@@ -53,6 +61,12 @@ export declare class RegalCli {
53
61
  * - 0 — no findings at or above `failLevel`
54
62
  * - 3 — findings present
55
63
  * - non-zero other — Regal-internal failure (config error, etc.)
64
+ *
65
+ * When called with inline `source`, location-bound rules whose
66
+ * verdict depends on the on-disk path (currently
67
+ * `directory-package-mismatch`) are auto-disabled because the
68
+ * randomized temp-file path makes those rules false positives.
69
+ * Callers that want them anyway can re-enable via `enable`.
56
70
  */
57
71
  lint(input: LintInput): Promise<SpawnResult>;
58
72
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"regal-cli.d.ts","sourceRoot":"","sources":["../../src/lib/regal-cli.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;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AAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQvC;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAgClD;;;OAGG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;YAUjC,cAAc;CAS7B"}
@@ -10,6 +10,14 @@ import { rm, writeFile } from 'node:fs/promises';
10
10
  import { tmpdir } from 'node:os';
11
11
  import { join } from 'node:path';
12
12
  import { runBinary } from './subprocess.js';
13
+ /**
14
+ * Rules whose verdict depends on the on-disk path of the file being
15
+ * linted. When a caller passes inline `source`, the file lives at a
16
+ * randomized temp path that can never match the source's declared
17
+ * package, so these rules always fire as false positives. Auto-disabled
18
+ * for inline source unless the caller explicitly re-enables them.
19
+ */
20
+ export const INLINE_SOURCE_FALSE_POSITIVE_RULES = ['directory-package-mismatch'];
13
21
  /**
14
22
  * Wrapper around the local `regal` binary.
15
23
  *
@@ -43,6 +51,12 @@ export class RegalCli {
43
51
  * - 0 — no findings at or above `failLevel`
44
52
  * - 3 — findings present
45
53
  * - non-zero other — Regal-internal failure (config error, etc.)
54
+ *
55
+ * When called with inline `source`, location-bound rules whose
56
+ * verdict depends on the on-disk path (currently
57
+ * `directory-package-mismatch`) are auto-disabled because the
58
+ * randomized temp-file path makes those rules false positives.
59
+ * Callers that want them anyway can re-enable via `enable`.
46
60
  */
47
61
  async lint(input) {
48
62
  if (!input.source && !input.paths?.length) {
@@ -57,9 +71,18 @@ export class RegalCli {
57
71
  args.push('--disable-all');
58
72
  if (input.enableAll)
59
73
  args.push('--enable-all');
60
- for (const rule of input.disable ?? [])
74
+ const userEnable = new Set(input.enable ?? []);
75
+ const userDisable = new Set(input.disable ?? []);
76
+ const effectiveDisable = new Set(userDisable);
77
+ if (input.source !== undefined) {
78
+ for (const rule of INLINE_SOURCE_FALSE_POSITIVE_RULES) {
79
+ if (!userEnable.has(rule))
80
+ effectiveDisable.add(rule);
81
+ }
82
+ }
83
+ for (const rule of effectiveDisable)
61
84
  args.push('--disable', rule);
62
- for (const rule of input.enable ?? [])
85
+ for (const rule of userEnable)
63
86
  args.push('--enable', rule);
64
87
  for (const cat of input.disableCategory ?? [])
65
88
  args.push('--disable-category', cat);
@@ -1 +1 @@
1
- {"version":3,"file":"regal-cli.js","sourceRoot":"","sources":["../../src/lib/regal-cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AA+B9D;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IACU;IAA7B,YAA6B,MA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O,CAAC,CAAC;QAClE,MAAM,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;gBAAS,CAAC;YACT,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF"}
package/dist/server.d.ts CHANGED
@@ -3,13 +3,25 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
4
4
  import { type Config } from './config.js';
5
5
  export declare const SERVER_NAME = "orygn-opa-mcp";
6
- export declare const SERVER_VERSION = "0.1.0";
6
+ export declare const SERVER_VERSION = "0.1.1";
7
7
  /**
8
8
  * Construct an `McpServer`, register every tool / prompt / resource
9
9
  * onto it, and return it. Exported for tests so they can drive a
10
10
  * fully-loaded server without standing up a stdio transport.
11
11
  */
12
12
  export declare function buildServer(config: Config): McpServer;
13
+ /**
14
+ * Probe the configured `opa` and `regal` binaries at startup and log
15
+ * warnings if either is unreachable. Runs in the background so it
16
+ * doesn't delay the MCP `initialize` handshake. Most users only see
17
+ * the failure when they call a tool; surfacing it early in the log
18
+ * file gives operators a place to look when diagnosing
19
+ * `OPA_BINARY_NOT_FOUND` (most often caused by Claude Desktop's
20
+ * reduced PATH on macOS and Windows).
21
+ *
22
+ * Exported for tests; production callers don't await it.
23
+ */
24
+ export declare function runStartupSelfCheck(config: Config): Promise<void>;
13
25
  /**
14
26
  * Entry-point flow: load config from env, build the server, connect
15
27
  * to the supplied transport (defaults to stdio for production).
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAMtD,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAC3C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAoBrD;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CASpE"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAQtD,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAC3C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAoBrD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BvE;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAepE"}
package/dist/server.js CHANGED
@@ -13,11 +13,13 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
13
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
14
14
  import { loadConfig } from './config.js';
15
15
  import { initLogger, logger } from './lib/logger.js';
16
+ import { OpaCli } from './lib/opa-cli.js';
17
+ import { RegalCli } from './lib/regal-cli.js';
16
18
  import { registerPrompts } from './prompts/index.js';
17
19
  import { registerResources } from './resources/index.js';
18
20
  import { registerTools } from './tools/index.js';
19
21
  export const SERVER_NAME = 'orygn-opa-mcp';
20
- export const SERVER_VERSION = '0.1.0';
22
+ export const SERVER_VERSION = '0.1.1';
21
23
  /**
22
24
  * Construct an `McpServer`, register every tool / prompt / resource
23
25
  * onto it, and return it. Exported for tests so they can drive a
@@ -40,6 +42,43 @@ export function buildServer(config) {
40
42
  registerResources(server, config);
41
43
  return server;
42
44
  }
45
+ /**
46
+ * Probe the configured `opa` and `regal` binaries at startup and log
47
+ * warnings if either is unreachable. Runs in the background so it
48
+ * doesn't delay the MCP `initialize` handshake. Most users only see
49
+ * the failure when they call a tool; surfacing it early in the log
50
+ * file gives operators a place to look when diagnosing
51
+ * `OPA_BINARY_NOT_FOUND` (most often caused by Claude Desktop's
52
+ * reduced PATH on macOS and Windows).
53
+ *
54
+ * Exported for tests; production callers don't await it.
55
+ */
56
+ export async function runStartupSelfCheck(config) {
57
+ const opa = new OpaCli(config);
58
+ const regal = new RegalCli(config);
59
+ const [opaVersion, regalVersion] = await Promise.all([
60
+ opa.version().catch(() => null),
61
+ regal.version().catch(() => null),
62
+ ]);
63
+ if (opaVersion === null) {
64
+ logger.warn('startup self-check: opa binary not reachable; rego_* tools will fail', {
65
+ opaBinary: config.opaBinary,
66
+ hint: 'set OPA_BINARY to an absolute path, or ensure opa is on PATH for the launching process. Most often hit under Claude Desktop, which spawns servers with a reduced PATH on macOS and Windows.',
67
+ });
68
+ }
69
+ else {
70
+ logger.info('startup self-check: opa OK', { version: opaVersion });
71
+ }
72
+ if (regalVersion === null) {
73
+ logger.warn('startup self-check: regal binary not reachable; rego_lint will return REGAL_NOT_FOUND', {
74
+ regalBinary: config.regalBinary,
75
+ hint: 'set REGAL_BINARY to an absolute path, or ensure regal is on PATH. Regal is optional; only rego_lint requires it.',
76
+ });
77
+ }
78
+ else {
79
+ logger.info('startup self-check: regal OK', { version: regalVersion });
80
+ }
81
+ }
43
82
  /**
44
83
  * Entry-point flow: load config from env, build the server, connect
45
84
  * to the supplied transport (defaults to stdio for production).
@@ -54,6 +93,10 @@ export async function main(transport) {
54
93
  const connectTo = transport ?? new StdioServerTransport();
55
94
  await server.connect(connectTo);
56
95
  logger.info('connected to transport, ready for requests');
96
+ // Fire-and-forget; do not block initialize on subprocess probes.
97
+ void runStartupSelfCheck(config).catch((cause) => {
98
+ logger.error('startup self-check threw unexpectedly', { error: cause });
99
+ });
57
100
  return server;
58
101
  }
59
102
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE;QACpC,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IA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ts","sourceRoot":"","sources":["../../../src/tools/authoring/lint.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAoC9C,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CA6DxE"}
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/tools/authoring/lint.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAoC9C,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA2BD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAiExE"}
@@ -31,11 +31,36 @@ const RegoLintInput = {
31
31
  .describe('Severity at which Regal returns a non-zero exit. Default: `error`.'),
32
32
  ignoreFiles: z.array(z.string()).optional().describe('Glob patterns to skip.'),
33
33
  };
34
+ /**
35
+ * Matches the temp filenames RegalCli writes inline source to. The
36
+ * basename anchor (`$`) is intentional: any path ending in our
37
+ * temp-file pattern is ours, regardless of whether the OS reports it
38
+ * with forward or back slashes or what tmpdir() resolves to.
39
+ */
40
+ const INLINE_TEMP_PATH = /orygn-opa-mcp-[0-9a-f-]+\.rego$/i;
41
+ /**
42
+ * Replace the leaking temp-file path in violation locations with
43
+ * `<inline>` when the call used inline source, so users see "this came
44
+ * from your inline source" instead of `/tmp/...orygn-opa-mcp-<uuid>.rego`.
45
+ * Returns a new array; the input is not mutated.
46
+ */
47
+ function rewriteInlineLocations(violations) {
48
+ return violations.map((violation) => {
49
+ const loc = violation.location;
50
+ if (!loc || typeof loc !== 'object')
51
+ return violation;
52
+ const locObj = loc;
53
+ const file = locObj['file'];
54
+ if (typeof file !== 'string' || !INLINE_TEMP_PATH.test(file))
55
+ return violation;
56
+ return { ...violation, location: { ...locObj, file: '<inline>' } };
57
+ });
58
+ }
34
59
  export function registerRegoLint(server, config) {
35
60
  const regal = new RegalCli(config);
36
61
  server.registerTool('rego_lint', {
37
62
  title: 'Lint Rego',
38
- description: 'Lint Rego source with the Regal linter. Returns categorized violations (style, bugs, idiomatic, performance) with file/line locations. Requires `regal` on PATH or `REGAL_BINARY` set; returns REGAL_NOT_FOUND otherwise. When called with inline `source` rather than `paths`, expect location-bound rules such as `directory-package-mismatch` to fire as artifacts of the randomized temp-file path. Prefer `paths` for canonical signal; for inline workflows, ignore or `disable` those rules.',
63
+ description: 'Lint Rego source with the Regal linter. Returns categorized violations (style, bugs, idiomatic, performance) with file/line locations. Requires `regal` on PATH or `REGAL_BINARY` set; returns REGAL_NOT_FOUND otherwise. When called with inline `source`, location-bound rules whose verdict depends on the on-disk path (`directory-package-mismatch`) are auto-disabled to avoid temp-file false positives, and `location.file` is reported as `<inline>` instead of the randomized temp path. Re-enable those rules via `enable` if your workflow actually needs them.',
39
64
  inputSchema: RegoLintInput,
40
65
  }, async (input) => {
41
66
  return withToolEnvelope(config, async () => {
@@ -73,8 +98,10 @@ export function registerRegoLint(server, config) {
73
98
  details: { stderr: result.stderr.trim(), exitCode: result.exitCode },
74
99
  });
75
100
  }
101
+ const rawViolations = parsed.violations ?? [];
102
+ const violations = source !== undefined ? rewriteInlineLocations(rawViolations) : rawViolations;
76
103
  return ok({
77
- violations: parsed.violations ?? [],
104
+ violations,
78
105
  notices: parsed.notices,
79
106
  summary: parsed.summary,
80
107
  });
@@ -1 +1 @@
1
- {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/tools/authoring/lint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;IAC9F,KAAK,EAAE,CAAC;SACL,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CACP,6FAA6F,CAC9F;IACH,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,sEAAsE,CAAC;IACnF,OAAO,EAAE,CAAC,C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AG,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChE,IAAI,iBAAiB;gBAAE,OAAO,iBAAiB,CAAC;YAEhD,MAAM,MAAM,GAAG,YAAY,CAAiB,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,GAAG,CAAC,eAAe,EAAE,+CAA+C,EAAE;oBAC3E,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;iBACrE,CAAC,CAAC;YACL,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;YAC9C,MAAM,UAAU,GACd,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YAE/E,OAAO,EAAE,CAAiB;gBACxB,UAAU;gBACV,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@orygn/opa-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "mcpName": "io.github.OrygnsCode/opa-mcp",
4
5
  "description": "Model Context Protocol server for Open Policy Agent (OPA). Author, validate, debug, and explain Rego policies through any MCP-compatible client.",
5
6
  "type": "module",
6
7
  "license": "MIT",
@@ -82,5 +83,8 @@
82
83
  "publishConfig": {
83
84
  "access": "public",
84
85
  "provenance": true
86
+ },
87
+ "overrides": {
88
+ "hono": ">=4.12.18"
85
89
  }
86
90
  }