@mcp-com-ai/plugin-sdk 1.0.1-beta.260912 → 1.0.2-beta.260914

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 CHANGED
@@ -1,48 +1,48 @@
1
- # @hapi/plugin-sdk
2
-
3
- The contract every HAPI CLI plugin implements.
4
-
5
- This package is intentionally tiny and stable. It exports:
6
-
7
- - `HapiCliPlugin` — the plugin shape the core CLI loads
8
- - `CliCommand` / `CliContext` / `CliInvocation` — the runtime types
9
- - `defineCommand` / `definePlugin` — identity helpers for IntelliSense + validation
10
- - `parseArgs` — a small, dependency-free flag parser
11
- - `renderCommandHelp` — consistent help output
12
- - `HAPI_CLI_API_VERSION` — the current plugin-contract version
13
-
14
- ## Writing a plugin
15
-
16
- ```ts
17
- import { definePlugin, defineCommand, HAPI_CLI_API_VERSION } from '@mcp-com-ai/plugin-sdk';
18
-
19
- const connect = defineCommand({
20
- name: 'connect',
21
- description: 'Connect to an MCP server',
22
- arguments: [{ name: 'server-url', description: 'Target MCP server URL', required: true }],
23
- async run({ positionals }, ctx) {
24
- const [url] = positionals;
25
- ctx.stdout.write(`Connecting to ${url}\n`);
26
- },
27
- });
28
-
29
- export default definePlugin({
30
- name: '@mcp-com-ai/client',
31
- version: '0.1.0',
32
- compatibility: { cliApiVersion: HAPI_CLI_API_VERSION },
33
- commands: [
34
- {
35
- name: 'client',
36
- description: 'MCP client operations',
37
- subcommands: [connect],
38
- },
39
- ],
40
- });
1
+ <!--
2
+ MCP.com.ai — Server Registry
3
+ Deploying & Registering MCP Servers
4
+ -->
5
+
6
+ <p align="center">
7
+ <img src="https://img.shields.io/badge/MCP-Model%20Context%20Protocol-1193b0?style=for-the-badge" />
8
+ <img src="https://img.shields.io/badge/Server%20Registry-Deploy%20%26%20Discover-da7756?style=for-the-badge" />
9
+ </p>
10
+
11
+ <h1 align="center">MCP Server Registry Integration</h1>
12
+
13
+ <p align="center">
14
+ <b>Build Once. Deploy Everywhere. Discover Globally.</b><br/>
15
+ Self-host, deploy, and register MCP servers with confidence using HAPI CLI, Docker, or Cloudflare Workers.
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="https://mcp.com.ai"><b>Website</b></a>
20
+ ·
21
+ <a href="https://docs.mcp.com.ai"><b>Docs</b></a>
22
+ ·
23
+ <a href="https://registry.modelcontextprotocol.io/?q=ai.com.mcp"><b>MCP Registry</b></a>
24
+ ·
25
+ <a href="https://run.mcp.com.ai"><b>Run MCP</b></a>
26
+ ·
27
+ <a href="https://hapi.mcp.com.ai"><b>HAPI CLI</b></a>
28
+ </p>
29
+
30
+ ---
31
+
32
+ # HAPI plugin SDK ![NPM Version](https://img.shields.io/npm/v/%40mcp-com-ai%2fhapi)
33
+
34
+ `@mcp-com-ai/plugin-sdk` is the contract that lets HAPI plugins work with the
35
+ `hapi` command. It is for plugin authors, not for people simply serving an API
36
+ or workflow as MCP.
37
+
38
+ To run an OpenAPI API or Arazzo workflow, install the CLI and the appropriate
39
+ document plugin instead:
40
+
41
+ ```sh
42
+ bun add -g @mcp-com-ai/hapi @mcp-com-ai/plugin-openapi
43
+ hapi serve --specs ./openapi.yaml --mcp
41
44
  ```
42
45
 
43
- ## Stability policy
44
-
45
- The SDK follows a simple rule: **additive changes keep the same
46
- `HAPI_CLI_API_VERSION`. Any breaking change bumps the major.** The CLI
47
- refuses to load plugins whose `compatibility.cliApiVersion` does not
48
- match the CLI's advertised version.
46
+ The CLI and first-party plugins install this package automatically. Keep it on
47
+ the same version as the HAPI packages that depend on it. Plugin-development
48
+ material is intentionally kept out of this end-user package guide.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  // @bun
2
- var M="1.0.1-beta.260912";var T=Number(M.split(".")[0]);function P(e){return e}function F(e){if(!e.name)throw Error("HAPI plugin missing required `name`");if(!e.version)throw Error(`HAPI plugin '${e.name}' missing required \`version\``);if(!e.compatibility?.cliApiVersion)throw Error(`HAPI plugin '${e.name}' must declare compatibility.cliApiVersion (current: '${T}')`);if(!Array.isArray(e.commands))throw Error(`HAPI plugin '${e.name}' must declare a commands[] array`);let r=new Set;for(let s of e.serveProviders??[]){if(!s.id||!s.kind||!s.rootField||!s.description)throw Error(`HAPI plugin '${e.name}' has an invalid serve provider declaration`);if(typeof s.serve!=="function")throw Error(`HAPI plugin '${e.name}' serve provider '${s.id}' must declare serve()`);if(r.has(s.id))throw Error(`HAPI plugin '${e.name}' declares duplicate serve provider '${s.id}'`);r.add(s.id)}return e}function H(e,r=[],s={}){let c=s.allowUnknown??!0,n=[],t=[],f={};for(let i of r)if(i.env&&process.env[i.env]!==void 0)f[i.name]=E(process.env[i.env],i);else if(i.default!==void 0)f[i.name]=i.default;let u=new Map,j=new Map;for(let i of r)if(u.set(i.name,i),i.alias)j.set(i.alias,i);let h=0;while(h<e.length){let i=e[h];if(i==="--"){t.push(...e.slice(h+1));break}if(i.startsWith("--")){let d=i.slice(2),R=d.indexOf("="),x=R>=0?d.slice(0,R):d,S=R>=0?d.slice(R+1):void 0,U=x.startsWith("no-"),V=U?x.slice(3):x,L=u.get(V)??u.get(Z(V));if(!L){if(!c)throw Error(`Unknown option: --${x}`);if(S!==void 0)f[D(x)]=S,h++;else if(U)f[D(V)]=!1,h++;else{let A=e[h+1];if(A!==void 0&&!String(A).startsWith("-"))f[D(x)]=A,h+=2;else f[D(x)]=!0,h++}continue}if(L.type==="boolean"){f[L.name]=U?!1:S?O(S):!0,h++;continue}let m=S;if(m===void 0)m=e[h+1],h+=m!==void 0&&!String(m).startsWith("-")?2:1;else h++;if(L.type==="array"){let A=f[L.name]??[];f[L.name]=[...A,...String(m??"").split(",").map((_)=>_.trim()).filter(Boolean)]}else f[L.name]=E(m,L);continue}if(i.startsWith("-")&&i.length>1){let d=i.slice(1),R=d.indexOf("="),x=R>=0?d.slice(0,R):d,S=R>=0?d.slice(R+1):void 0,U=j.get(x);if(!U){if(!c)throw Error(`Unknown option: -${x}`);n.push(i),h++;continue}if(U.type==="boolean"){f[U.name]=S?O(S):!0,h++;continue}let V=S;if(V===void 0)V=e[h+1],h+=V!==void 0&&!String(V).startsWith("-")?2:1;else h++;f[U.name]=E(V,U);continue}n.push(i),h++}return{positionals:n,options:f,rest:t}}function E(e,r){if(e===void 0)return e;switch(r.type){case"number":{let s=Number(e);return Number.isFinite(s)?s:e}case"boolean":return O(e);case"array":return String(e).split(",").map((s)=>s.trim()).filter(Boolean);default:return String(e)}}function O(e){if(typeof e==="boolean")return e;let r=String(e).toLowerCase();return r==="1"||r==="true"||r==="yes"||r==="on"}function Z(e){return e.replace(/-([a-z0-9])/g,(r,s)=>s.toUpperCase())}function D(e){return Z(e)}function W(e,r,s=[]){let c=s.length?`${s.join(" ")} `:"",n=(t)=>r.stdout.write(t);if(n(`
3
- ${c}${e.name} \u2014 ${e.description}
4
- `),e.arguments?.length){n(`
2
+ var k="1.0.2-beta.260914";var P=Number(k.split(".")[0]);function V(e){return e}function N(e){if(!e.name)throw Error("HAPI plugin missing required `name`");if(!e.version)throw Error(`HAPI plugin '${e.name}' missing required \`version\``);if(!e.compatibility?.cliApiVersion)throw Error(`HAPI plugin '${e.name}' must declare compatibility.cliApiVersion (current: '${P}')`);if(!Array.isArray(e.commands))throw Error(`HAPI plugin '${e.name}' must declare a commands[] array`);let n=new Set;for(let t of e.serveProviders??[]){if(!t.id||!t.kind||!t.rootField||!t.description)throw Error(`HAPI plugin '${e.name}' has an invalid serve provider declaration`);if(typeof t.serve!=="function")throw Error(`HAPI plugin '${e.name}' serve provider '${t.id}' must declare serve()`);if(n.has(t.id))throw Error(`HAPI plugin '${e.name}' declares duplicate serve provider '${t.id}'`);n.add(t.id)}return e}function L(e,n=[],t={}){let a=t.allowUnknown??!0,i=[],r=[],o={},l=[];for(let s of n)if(s.env&&process.env[s.env]!==void 0)o[s.name]=w(process.env[s.env],s);else if(s.default!==void 0)o[s.name]=s.default;let u=new Map,I=new Map;for(let s of n)if(u.set(s.name,s),s.alias)I.set(s.alias,s);let c=0;while(c<e.length){let s=e[c];if(s==="--"){r.push(...e.slice(c+1));break}if(s.startsWith("--")){let p=s.slice(2),m=p.indexOf("="),d=m>=0?p.slice(0,m):p,f=m>=0?p.slice(m+1):void 0,g=d.startsWith("no-"),h=g?d.slice(3):d,C=u.get(h)??u.get(R(h));if(!C){if(!a)throw Error(`Unknown option: --${d}`);if(l.push(d),f!==void 0)o[v(d)]=f,c++;else if(g)o[v(h)]=!1,c++;else{let x=e[c+1];if(x!==void 0&&!String(x).startsWith("-"))o[v(d)]=x,c+=2;else o[v(d)]=!0,c++}continue}if(C.type==="boolean"){o[C.name]=g?!1:f?A(f):!0,c++;continue}let b=f;if(b===void 0)b=e[c+1],c+=b!==void 0&&!String(b).startsWith("-")?2:1;else c++;if(C.type==="array"){let x=o[C.name]??[];o[C.name]=[...x,...String(b??"").split(",").map((H)=>H.trim()).filter(Boolean)]}else o[C.name]=w(b,C);continue}if(s.startsWith("-")&&s.length>1){let p=s.slice(1),m=p.indexOf("="),d=m>=0?p.slice(0,m):p,f=m>=0?p.slice(m+1):void 0,g=I.get(d);if(!g){if(!a)throw Error(`Unknown option: -${d}`);i.push(s),c++;continue}if(g.type==="boolean"){o[g.name]=f?A(f):!0,c++;continue}let h=f;if(h===void 0)h=e[c+1],c+=h!==void 0&&!String(h).startsWith("-")?2:1;else c++;o[g.name]=w(h,g);continue}i.push(s),c++}return{positionals:i,options:o,rest:r,unknownOptions:l}}function w(e,n){if(e===void 0)return e;switch(n.type){case"number":{let t=Number(e);return Number.isFinite(t)?t:e}case"boolean":return A(e);case"array":return String(e).split(",").map((t)=>t.trim()).filter(Boolean);default:return String(e)}}function A(e){if(typeof e==="boolean")return e;let n=String(e).toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function R(e){return e.replace(/-([a-z0-9])/g,(n,t)=>t.toUpperCase())}function v(e){return R(e)}function _(e,n,t=[]){let a=t.length?`${t.join(" ")} `:"",i=(r)=>n.stdout.write(r);if(i(`
3
+ ${a}${e.name} \u2014 ${e.description}
4
+ `),e.arguments?.length){i(`
5
5
  Arguments:
6
- `);for(let t of e.arguments){let f=t.variadic?`${t.name}...`:t.name,u=t.required?`<${f}>`:`[${f}]`;n(` ${u.padEnd(24)} ${t.description}
7
- `)}}if(e.options?.length){n(`
6
+ `);for(let r of e.arguments){let o=r.variadic?`${r.name}...`:r.name,l=r.required?`<${o}>`:`[${o}]`;i(` ${l.padEnd(24)} ${r.description}
7
+ `)}}if(e.options?.length){i(`
8
8
  Options:
9
- `);for(let t of e.options){let f=t.alias?`-${t.alias}, --${t.name}`:` --${t.name}`,u=t.default!==void 0?`${t.description} (default: ${JSON.stringify(t.default)})`:t.description;n(` ${f.padEnd(28)} ${u}
10
- `)}}if(e.subcommands?.length){n(`
9
+ `);for(let r of e.options){let o=r.alias?`-${r.alias}, --${r.name}`:` --${r.name}`,l=r.default!==void 0?`${r.description} (default: ${JSON.stringify(r.default)})`:r.description;i(` ${o.padEnd(28)} ${l}
10
+ `)}}if(e.subcommands?.length){i(`
11
11
  Subcommands:
12
- `);for(let t of e.subcommands){if(t.hidden)continue;n(` ${t.name.padEnd(14)} ${t.description}
13
- `)}}if(e.longHelp)n(`
12
+ `);for(let r of e.subcommands){if(r.hidden)continue;i(` ${r.name.padEnd(14)} ${r.description}
13
+ `)}}if(e.longHelp)i(`
14
14
  ${e.longHelp}
15
- `);n(`
16
- `)}var Y=Object.freeze({maxBytes:5242880,timeoutMs:1e4,maxRedirects:5});function B(e){if(e.protocol!=="http:"&&e.protocol!=="https:")throw Error(`Remote documents cannot resolve ${e.protocol} sources`)}function b(e){try{let r=e instanceof URL?new URL(e.href):new URL(e);if(r.username="",r.password="",r.search)r.search="?redacted";return r.href}catch{return String(e)}}var G=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/,$=/^(<=|>=|<|>|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z.-]+)?)$/;function J(e,r){let s=C(e);if(!s||!y(r))return!1;if(r.startsWith("^")){let n=C(r.slice(1));return n!==void 0&&z(s,n)>=0&&z(s,K(n))<0}let c=r.trim().split(/\s+/).filter(Boolean);return c.length>0&&c.every((n)=>{let t=n.match($);if(!t)return!1;let f=t[2];if(!f)return!1;let u=C(f);if(!u)return!1;let j=z(s,u);switch(t[1]??"="){case"=":return j===0;case">":return j>0;case">=":return j>=0;case"<":return j<0;case"<=":return j<=0;default:return!1}})}function y(e){if(e.startsWith("^"))return C(e.slice(1))!==void 0;let r=e.trim().split(/\s+/).filter(Boolean);return r.length>0&&r.every((s)=>{let n=s.match($)?.[2];return n!==void 0&&C(n)!==void 0})}function C(e){let r=e.match(G);if(!r)return;return{major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:r[4]?.split(".")??[]}}function K(e){if(e.major>0)return{major:e.major+1,minor:0,patch:0,prerelease:["0"]};if(e.minor>0)return{major:0,minor:e.minor+1,patch:0,prerelease:["0"]};return{major:0,minor:0,patch:e.patch+1,prerelease:["0"]}}function z(e,r){for(let c of["major","minor","patch"])if(e[c]!==r[c])return e[c]<r[c]?-1:1;if(e.prerelease.length===0||r.prerelease.length===0){if(e.prerelease.length===r.prerelease.length)return 0;return e.prerelease.length===0?1:-1}let s=Math.max(e.prerelease.length,r.prerelease.length);for(let c=0;c<s;c++){let n=e.prerelease[c],t=r.prerelease[c];if(n===void 0)return-1;if(t===void 0)return 1;if(n===t)continue;let f=/^\d+$/.test(n),u=/^\d+$/.test(t);if(f&&u)return Number(n)<Number(t)?-1:1;if(f!==u)return f?-1:1;return n<t?-1:1}return 0}export{J as satisfiesVersionRange,W as renderCommandHelp,b as redactDocumentUrl,H as parseArgs,y as isSupportedVersionRange,F as definePlugin,P as defineCommand,B as assertRemoteDocumentUrl,T as HAPI_CLI_API_VERSION,Y as DEFAULT_DOCUMENT_SOURCE_POLICY};
15
+ `);i(`
16
+ `)}var j=Object.freeze({maxBytes:5242880,timeoutMs:1e4,maxRedirects:5});function D(e){if(e.protocol!=="http:"&&e.protocol!=="https:")throw Error(`Remote documents cannot resolve ${e.protocol} sources`)}function W(e){try{let n=e instanceof URL?new URL(e.href):new URL(e);if(n.username="",n.password="",n.search)n.search="?redacted";return n.href}catch{return String(e)}}var q=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/,E=/^(<=|>=|<|>|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z.-]+)?)$/;function M(e,n){let t=y(e);if(!t||!O(n))return!1;if(n.startsWith("^")){let i=y(n.slice(1));return i!==void 0&&S(t,i)>=0&&S(t,T(i))<0}let a=n.trim().split(/\s+/).filter(Boolean);return a.length>0&&a.every((i)=>{let r=i.match(E);if(!r)return!1;let o=r[2];if(!o)return!1;let l=y(o);if(!l)return!1;let u=S(t,l);switch(r[1]??"="){case"=":return u===0;case">":return u>0;case">=":return u>=0;case"<":return u<0;case"<=":return u<=0;default:return!1}})}function O(e){if(e.startsWith("^"))return y(e.slice(1))!==void 0;let n=e.trim().split(/\s+/).filter(Boolean);return n.length>0&&n.every((t)=>{let i=t.match(E)?.[2];return i!==void 0&&y(i)!==void 0})}function y(e){let n=e.match(q);if(!n)return;return{major:Number(n[1]),minor:Number(n[2]),patch:Number(n[3]),prerelease:n[4]?.split(".")??[]}}function T(e){if(e.major>0)return{major:e.major+1,minor:0,patch:0,prerelease:["0"]};if(e.minor>0)return{major:0,minor:e.minor+1,patch:0,prerelease:["0"]};return{major:0,minor:0,patch:e.patch+1,prerelease:["0"]}}function S(e,n){for(let a of["major","minor","patch"])if(e[a]!==n[a])return e[a]<n[a]?-1:1;if(e.prerelease.length===0||n.prerelease.length===0){if(e.prerelease.length===n.prerelease.length)return 0;return e.prerelease.length===0?1:-1}let t=Math.max(e.prerelease.length,n.prerelease.length);for(let a=0;a<t;a++){let i=e.prerelease[a],r=n.prerelease[a];if(i===void 0)return-1;if(r===void 0)return 1;if(i===r)continue;let o=/^\d+$/.test(i),l=/^\d+$/.test(r);if(o&&l)return Number(i)<Number(r)?-1:1;if(o!==l)return o?-1:1;return i<r?-1:1}return 0}export{j as DEFAULT_DOCUMENT_SOURCE_POLICY,P as HAPI_CLI_API_VERSION,D as assertRemoteDocumentUrl,V as defineCommand,N as definePlugin,O as isSupportedVersionRange,L as parseArgs,W as redactDocumentUrl,_ as renderCommandHelp,M as satisfiesVersionRange};
package/dist/types.d.ts CHANGED
@@ -90,6 +90,15 @@ export interface CliInvocation {
90
90
  positionals: string[];
91
91
  options: Record<string, unknown>;
92
92
  rest: string[];
93
+ /**
94
+ * Flags on argv that didn't match any declared CliOption (by name or its
95
+ * kebab/camel variant), e.g. from a typo like --project-name instead of
96
+ * --project. Still parsed into `options` under a best-guess key (so
97
+ * intentional passthrough, like wrangler --var forwarding, keeps working),
98
+ * but callers should warn on these — a silently-ignored typo'd flag is
99
+ * much harder to notice than a merely-unused one.
100
+ */
101
+ unknownOptions?: string[];
93
102
  }
94
103
  /** A parsed source passed from the CLI to a document-specific serve provider. */
95
104
  export interface DocumentSourceEnvelope {
@@ -120,6 +129,8 @@ export interface ServeProvider {
120
129
  rootField: string;
121
130
  description: string;
122
131
  options?: readonly CliOption[];
132
+ /** Optional long-form help appended below the generic `hapi serve --help` block. */
133
+ longHelp?: string;
123
134
  /** Permit legacy identifiers that do not resolve to a document, e.g. an OpenAPI project name. */
124
135
  legacyFallback?: boolean;
125
136
  serve: (request: ServeProviderRequest, context: CliContext) => Promise<number | void> | number | void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-com-ai/plugin-sdk",
3
- "version": "1.0.1-beta.260912",
3
+ "version": "1.0.2-beta.260914",
4
4
  "description": "The shared plugin contract for the HAPI CLI. Consumed by the core CLI, first-party plugins, and third-party extensions.",
5
5
  "license": "LRL-CL",
6
6
  "type": "module",
@@ -24,10 +24,10 @@
24
24
  "typescript": "^5"
25
25
  },
26
26
  "engines": {
27
- "bun": ">=1.3.0"
28
- },
29
- "publishConfig": {
30
- "access": "public"
31
- },
32
- "keywords": ["hapi", "hapi-plugin", "mcp", "cli"]
27
+ "bun": ">=1.3.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "keywords": ["hapi", "hapi-plugin", "mcp", "cli"]
33
33
  }