@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 +46 -46
- package/dist/index.js +11 -11
- package/dist/types.d.ts +11 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
3
|
-
${
|
|
4
|
-
`),e.arguments?.length){
|
|
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
|
|
7
|
-
`)}}if(e.options?.length){
|
|
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
|
|
10
|
-
`)}}if(e.subcommands?.length){
|
|
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
|
|
13
|
-
`)}}if(e.longHelp)
|
|
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
|
-
`);
|
|
16
|
-
`)}var
|
|
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.
|
|
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
|
-
|
|
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
|
}
|