@skillit/target-mcp-protocol 2.0.0
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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/frontmatter.d.ts +89 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +80 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/render.d.ts +50 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +96 -0
- package/dist/render.js.map +1 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Pradeep Mouli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @skillit/target-mcp-protocol
|
|
2
|
+
|
|
3
|
+
> Default invocation-target adapter for `@skillit/mcp`. Emits `mcp:` frontmatter for agent harnesses that speak MCP natively.
|
|
4
|
+
|
|
5
|
+
Pairs with [`@skillit/mcp`](../mcp/) — when a host extracts or bundles an MCP server, this adapter renders a SKILL.md whose frontmatter is consumed directly by MCP-native harnesses (OpenCode, Codex, Cursor, Claude Code) so the harness can wire up the server without a separate connect step.
|
|
6
|
+
|
|
7
|
+
This is the **default** adapter — when you don't pass `--invocation`, this is what runs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
This adapter ships as a runtime dependency of `@skillit/mcp`. You do not need to install it explicitly. It's listed here for clarity:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --save-dev @skillit/target-mcp-protocol
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When to pick this target
|
|
22
|
+
|
|
23
|
+
Pick `mcp-protocol` (or omit `--invocation` entirely) when **the agent harness speaks the MCP protocol natively** — i.e., it can hold an MCP session and dispatch `tools/call`, `resources/read`, and `prompts/get` requests against the server.
|
|
24
|
+
|
|
25
|
+
This covers most modern agent harnesses:
|
|
26
|
+
|
|
27
|
+
- Claude Code (Anthropic CLI)
|
|
28
|
+
- Codex
|
|
29
|
+
- Cursor
|
|
30
|
+
- OpenCode
|
|
31
|
+
- Any IDE plugin that wires `mcp:` config into its agent
|
|
32
|
+
|
|
33
|
+
Don't pick it for shell-only harnesses (those need `cli:mcpc` or `cli:fastmcp` — see the sibling target packages).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## What it emits
|
|
38
|
+
|
|
39
|
+
`SKILL.md` frontmatter is augmented with an `mcp:` block:
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
---
|
|
43
|
+
name: filesystem
|
|
44
|
+
description: 'Secure file system access scoped to /tmp...'
|
|
45
|
+
license: MIT
|
|
46
|
+
mcp:
|
|
47
|
+
filesystem:
|
|
48
|
+
command: npx
|
|
49
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp']
|
|
50
|
+
---
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For HTTP transports the block uses `url` + `headers` instead of `command` + `args`. The host (`@skillit/mcp`) decides which form via `AdapterRenderContext.httpEndpoint` vs `.launchCommand`.
|
|
54
|
+
|
|
55
|
+
The body of the SKILL.md (Quick Reference, References section, tool/resource/prompt content) comes from the default core renderer — this adapter does not override `skipDefaultFunctionsRef`. It only injects `additionalFrontmatter`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Adapter contract
|
|
60
|
+
|
|
61
|
+
| Field | Value |
|
|
62
|
+
| ---------------------------- | --------------------------------------------- |
|
|
63
|
+
| `target` | `'mcp-protocol'` |
|
|
64
|
+
| `fingerprint.adapter` | `'@skillit/target-mcp-protocol'` |
|
|
65
|
+
| `fingerprint.version` | This package's `version` from `package.json`. |
|
|
66
|
+
| `fingerprint.targetCliRange` | _absent_ (this target invokes no CLI). |
|
|
67
|
+
|
|
68
|
+
Unlike the CLI-as-proxy adapters (`@skillit/target-mcpc`, `@skillit/target-fastmcp`), this adapter does **not** emit a `generated-by:` frontmatter block. The freshness audit (M5) tracks adapter-version drift only for CLI adapters — the `mcp-protocol` adapter has no upstream CLI shape to compare against, so the `fingerprint` is exposed only via the programmatic API (`McpProtocolAdapter.fingerprint`) for consumers that want to record it themselves.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Programmatic use
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import McpProtocolAdapter from '@skillit/target-mcp-protocol';
|
|
76
|
+
import { renderSkill } from '@skillit/core';
|
|
77
|
+
|
|
78
|
+
const rendered = await renderSkill(skill, { invocation: McpProtocolAdapter });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Further reading
|
|
84
|
+
|
|
85
|
+
- [`@skillit/mcp` README](../mcp/README.md) — host package, CLI usage, programmatic API.
|
|
86
|
+
- [`docs/adapter-authoring.md`](../mcp/docs/adapter-authoring.md) — building your own invocation adapter.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter composition for the `mcp-protocol` invocation target.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* MCP-native agent harnesses (OpenCode, Codex, Cursor) discover MCP server
|
|
6
|
+
* launch parameters from a `mcp:` frontmatter block in `SKILL.md`. This module
|
|
7
|
+
* builds the structured object that the core renderer's `additionalFrontmatter`
|
|
8
|
+
* mechanism serializes via the `yaml` package.
|
|
9
|
+
*
|
|
10
|
+
* Per research.md §7, the shape is one of:
|
|
11
|
+
*
|
|
12
|
+
* Stdio (command-based):
|
|
13
|
+
*
|
|
14
|
+
* ```yaml
|
|
15
|
+
* mcp:
|
|
16
|
+
* <skillName>:
|
|
17
|
+
* command: npx
|
|
18
|
+
* args:
|
|
19
|
+
* - -y
|
|
20
|
+
* - "@modelcontextprotocol/server-filesystem"
|
|
21
|
+
* env:
|
|
22
|
+
* FOO: bar
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* HTTP (url-based):
|
|
26
|
+
*
|
|
27
|
+
* ```yaml
|
|
28
|
+
* mcp:
|
|
29
|
+
* <skillName>:
|
|
30
|
+
* url: https://example.com/mcp
|
|
31
|
+
* headers:
|
|
32
|
+
* Authorization: Bearer test
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @module frontmatter
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Stdio launch shape — what the agent harness should spawn to talk to this server
|
|
39
|
+
* over stdio.
|
|
40
|
+
*/
|
|
41
|
+
export interface McpStdioLaunchCommand {
|
|
42
|
+
/** Executable to spawn (e.g. `npx`, `node`, `uvx`). */
|
|
43
|
+
readonly command: string;
|
|
44
|
+
/** Argument vector. Omitted from emitted YAML when empty/undefined. */
|
|
45
|
+
readonly args?: readonly string[];
|
|
46
|
+
/** Environment variables. Omitted from emitted YAML when empty/undefined. */
|
|
47
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* HTTP endpoint shape — used when the MCP server speaks Streamable HTTP/SSE
|
|
51
|
+
* rather than stdio. Conventional shape supported by Claude Desktop / OpenCode
|
|
52
|
+
* for HTTP-transport servers.
|
|
53
|
+
*/
|
|
54
|
+
export interface McpHttpLaunchCommand {
|
|
55
|
+
/** HTTP(S) URL of the MCP endpoint. */
|
|
56
|
+
readonly url: string;
|
|
57
|
+
/** Optional headers (e.g. `Authorization`). Omitted from emitted YAML when empty/undefined. */
|
|
58
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* MCP launch descriptor — discriminated union of stdio (`command`) and HTTP
|
|
62
|
+
* (`url`) shapes.
|
|
63
|
+
*/
|
|
64
|
+
export type McpLaunchCommand = McpStdioLaunchCommand | McpHttpLaunchCommand;
|
|
65
|
+
/**
|
|
66
|
+
* Build the structured `mcp:` frontmatter object for the default invocation target.
|
|
67
|
+
*
|
|
68
|
+
* The returned object is a plain JavaScript object — NOT a YAML string. The host
|
|
69
|
+
* renderer (in `@skillit/core`) merges it into the SKILL.md frontmatter via
|
|
70
|
+
* `SkillRenderOptions.additionalFrontmatter` and serializes through the `yaml`
|
|
71
|
+
* package, which handles quoting and indentation.
|
|
72
|
+
*
|
|
73
|
+
* Field order:
|
|
74
|
+
*
|
|
75
|
+
* Stdio shape — `{ command, args?, env? }`:
|
|
76
|
+
* 1. `command` (always present)
|
|
77
|
+
* 2. `args` (omitted when undefined or empty)
|
|
78
|
+
* 3. `env` (omitted when undefined or empty)
|
|
79
|
+
*
|
|
80
|
+
* HTTP shape — `{ url, headers? }`:
|
|
81
|
+
* 1. `url` (always present)
|
|
82
|
+
* 2. `headers` (omitted when undefined or empty)
|
|
83
|
+
*
|
|
84
|
+
* @param skillName - kebab-case skill identifier; becomes the inner mapping key.
|
|
85
|
+
* @param launchCommand - command+args+env (stdio) or url+headers (http) to embed.
|
|
86
|
+
* @returns `{ mcp: { [skillName]: <inner> } }` ready for yaml serialization.
|
|
87
|
+
*/
|
|
88
|
+
export declare function emitMcpFrontmatter(skillName: string, launchCommand: McpLaunchCommand): Record<string, unknown>;
|
|
89
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,gBAAgB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBzB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter composition for the `mcp-protocol` invocation target.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* MCP-native agent harnesses (OpenCode, Codex, Cursor) discover MCP server
|
|
6
|
+
* launch parameters from a `mcp:` frontmatter block in `SKILL.md`. This module
|
|
7
|
+
* builds the structured object that the core renderer's `additionalFrontmatter`
|
|
8
|
+
* mechanism serializes via the `yaml` package.
|
|
9
|
+
*
|
|
10
|
+
* Per research.md §7, the shape is one of:
|
|
11
|
+
*
|
|
12
|
+
* Stdio (command-based):
|
|
13
|
+
*
|
|
14
|
+
* ```yaml
|
|
15
|
+
* mcp:
|
|
16
|
+
* <skillName>:
|
|
17
|
+
* command: npx
|
|
18
|
+
* args:
|
|
19
|
+
* - -y
|
|
20
|
+
* - "@modelcontextprotocol/server-filesystem"
|
|
21
|
+
* env:
|
|
22
|
+
* FOO: bar
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* HTTP (url-based):
|
|
26
|
+
*
|
|
27
|
+
* ```yaml
|
|
28
|
+
* mcp:
|
|
29
|
+
* <skillName>:
|
|
30
|
+
* url: https://example.com/mcp
|
|
31
|
+
* headers:
|
|
32
|
+
* Authorization: Bearer test
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @module frontmatter
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Build the structured `mcp:` frontmatter object for the default invocation target.
|
|
39
|
+
*
|
|
40
|
+
* The returned object is a plain JavaScript object — NOT a YAML string. The host
|
|
41
|
+
* renderer (in `@skillit/core`) merges it into the SKILL.md frontmatter via
|
|
42
|
+
* `SkillRenderOptions.additionalFrontmatter` and serializes through the `yaml`
|
|
43
|
+
* package, which handles quoting and indentation.
|
|
44
|
+
*
|
|
45
|
+
* Field order:
|
|
46
|
+
*
|
|
47
|
+
* Stdio shape — `{ command, args?, env? }`:
|
|
48
|
+
* 1. `command` (always present)
|
|
49
|
+
* 2. `args` (omitted when undefined or empty)
|
|
50
|
+
* 3. `env` (omitted when undefined or empty)
|
|
51
|
+
*
|
|
52
|
+
* HTTP shape — `{ url, headers? }`:
|
|
53
|
+
* 1. `url` (always present)
|
|
54
|
+
* 2. `headers` (omitted when undefined or empty)
|
|
55
|
+
*
|
|
56
|
+
* @param skillName - kebab-case skill identifier; becomes the inner mapping key.
|
|
57
|
+
* @param launchCommand - command+args+env (stdio) or url+headers (http) to embed.
|
|
58
|
+
* @returns `{ mcp: { [skillName]: <inner> } }` ready for yaml serialization.
|
|
59
|
+
*/
|
|
60
|
+
export function emitMcpFrontmatter(skillName, launchCommand) {
|
|
61
|
+
const inner = {};
|
|
62
|
+
if ('url' in launchCommand) {
|
|
63
|
+
inner['url'] = launchCommand.url;
|
|
64
|
+
if (launchCommand.headers && Object.keys(launchCommand.headers).length > 0) {
|
|
65
|
+
inner['headers'] = { ...launchCommand.headers };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
inner['command'] = launchCommand.command;
|
|
70
|
+
if (launchCommand.args && launchCommand.args.length > 0) {
|
|
71
|
+
// Copy to a mutable plain array so YAML lib treats it as a sequence.
|
|
72
|
+
inner['args'] = [...launchCommand.args];
|
|
73
|
+
}
|
|
74
|
+
if (launchCommand.env && Object.keys(launchCommand.env).length > 0) {
|
|
75
|
+
inner['env'] = { ...launchCommand.env };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { mcp: { [skillName]: inner } };
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAiCH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,aAA+B;IAE/B,MAAM,KAAK,GAA4B,EAAE,CAAC;IAE1C,IAAI,KAAK,IAAI,aAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC;QACjC,IAAI,aAAa,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC;QACzC,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,qEAAqE;YACrE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,aAAa,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@skillit/target-mcp-protocol` — default invocation-target adapter.
|
|
3
|
+
*
|
|
4
|
+
* Resolved by `@skillit/mcp`'s adapter loader when the `mcp-protocol` target
|
|
5
|
+
* is requested. Emits SKILL.md with `mcp:` frontmatter that MCP-native agent
|
|
6
|
+
* harnesses (OpenCode, Codex, Cursor) parse to launch the server over stdio.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { McpProtocolAdapter } from './render.js';
|
|
11
|
+
export { emitMcpFrontmatter } from './frontmatter.js';
|
|
12
|
+
export type { McpLaunchCommand, McpStdioLaunchCommand, McpHttpLaunchCommand } from './frontmatter.js';
|
|
13
|
+
export { PACKAGE_VERSION } from './version.js';
|
|
14
|
+
import { McpProtocolAdapter } from './render.js';
|
|
15
|
+
declare const adapter: McpProtocolAdapter;
|
|
16
|
+
/**
|
|
17
|
+
* Default export — singleton adapter instance resolved by the adapter loader.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import adapter from '@skillit/target-mcp-protocol';
|
|
22
|
+
* await adapter.render(skill, ctx);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export default adapter;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,QAAA,MAAM,OAAO,oBAA2B,CAAC;AAEzC;;;;;;;;GAQG;AACH,eAAe,OAAO,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@skillit/target-mcp-protocol` — default invocation-target adapter.
|
|
3
|
+
*
|
|
4
|
+
* Resolved by `@skillit/mcp`'s adapter loader when the `mcp-protocol` target
|
|
5
|
+
* is requested. Emits SKILL.md with `mcp:` frontmatter that MCP-native agent
|
|
6
|
+
* harnesses (OpenCode, Codex, Cursor) parse to launch the server over stdio.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { McpProtocolAdapter } from './render.js';
|
|
11
|
+
export { emitMcpFrontmatter } from './frontmatter.js';
|
|
12
|
+
export { PACKAGE_VERSION } from './version.js';
|
|
13
|
+
import { McpProtocolAdapter } from './render.js';
|
|
14
|
+
const adapter = new McpProtocolAdapter();
|
|
15
|
+
/**
|
|
16
|
+
* Default export — singleton adapter instance resolved by the adapter loader.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import adapter from '@skillit/target-mcp-protocol';
|
|
21
|
+
* await adapter.render(skill, ctx);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export default adapter;
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAEzC;;;;;;;;GAQG;AACH,eAAe,OAAO,CAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `McpProtocolAdapter` — default invocation adapter for MCP-native harnesses.
|
|
3
|
+
*
|
|
4
|
+
* Delegates body rendering to `@skillit/core`'s default path and injects the
|
|
5
|
+
* `mcp:` frontmatter that tells OpenCode/Codex/Cursor how to launch the server.
|
|
6
|
+
* Inherits resources/prompts reference emission from core's shared helpers.
|
|
7
|
+
*
|
|
8
|
+
* @module render
|
|
9
|
+
*/
|
|
10
|
+
import type { AdapterFingerprint, AdapterRenderContext, ExtractedSkill, RenderedSkill } from '@skillit/core';
|
|
11
|
+
import type { InvocationAdapter } from '@skillit/mcp';
|
|
12
|
+
/**
|
|
13
|
+
* Default invocation adapter: emits SKILL.md with `mcp:` frontmatter that
|
|
14
|
+
* MCP-native agent harnesses parse to launch the server over stdio or
|
|
15
|
+
* connect to it over HTTP.
|
|
16
|
+
*
|
|
17
|
+
* Launch-shape resolution narrows on `ctx.mode` (per data-model.md §1):
|
|
18
|
+
*
|
|
19
|
+
* 1. **`mode: 'bundle'`** — the host bundle command flagged this skill as
|
|
20
|
+
* self-referential. Emits `command: npx` + `args: [-y, <packageName>]`
|
|
21
|
+
* (or the multi-bin `--package=<pkg> <bin>` form per FR-034).
|
|
22
|
+
* 2. **`mode: 'http'`** — emits a `{ url, headers? }` shape (no shell launch).
|
|
23
|
+
* 3. **`mode: 'stdio'`** — `ctx.launchCommand` is used verbatim.
|
|
24
|
+
*
|
|
25
|
+
* The renderer's invocation-adapter dispatch in `@skillit/core` guarantees
|
|
26
|
+
* `mode` is always one of these three arms, so the previous runtime
|
|
27
|
+
* `MISSING_LAUNCH_COMMAND` throw is no longer needed at the adapter level.
|
|
28
|
+
* An exhaustive `default` branch is kept for compile-time exhaustiveness.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* The adapter does NOT render its own body content — it calls `renderSkill`
|
|
32
|
+
* with `invocation: undefined` to dispatch through core's default synchronous
|
|
33
|
+
* path, then injects the structured frontmatter object via
|
|
34
|
+
* `additionalFrontmatter`. This guarantees parity with non-MCP skills and means
|
|
35
|
+
* future renderer features (Quick Reference enhancements, new sections) work
|
|
36
|
+
* out of the box for MCP skills too.
|
|
37
|
+
*/
|
|
38
|
+
export declare class McpProtocolAdapter implements InvocationAdapter {
|
|
39
|
+
readonly target: "mcp-protocol";
|
|
40
|
+
readonly fingerprint: AdapterFingerprint;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Render an `ExtractedSkill` into a `RenderedSkill` carrying `mcp:` frontmatter.
|
|
44
|
+
*
|
|
45
|
+
* Narrows on `ctx.mode` to pick the launch shape — see the class-level
|
|
46
|
+
* docstring for the per-arm dialect.
|
|
47
|
+
*/
|
|
48
|
+
render(skill: ExtractedSkill, ctx: AdapterRenderContext): Promise<RenderedSkill>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,kBAAmB,YAAW,iBAAiB;IAC1D,QAAQ,CAAC,MAAM,EAAG,cAAc,CAAU;IAC1C,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;;IASzC;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC;CA4CvF"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `McpProtocolAdapter` — default invocation adapter for MCP-native harnesses.
|
|
3
|
+
*
|
|
4
|
+
* Delegates body rendering to `@skillit/core`'s default path and injects the
|
|
5
|
+
* `mcp:` frontmatter that tells OpenCode/Codex/Cursor how to launch the server.
|
|
6
|
+
* Inherits resources/prompts reference emission from core's shared helpers.
|
|
7
|
+
*
|
|
8
|
+
* @module render
|
|
9
|
+
*/
|
|
10
|
+
import { renderSkill } from '@skillit/core';
|
|
11
|
+
import { emitMcpFrontmatter } from './frontmatter.js';
|
|
12
|
+
import { PACKAGE_VERSION } from './version.js';
|
|
13
|
+
/**
|
|
14
|
+
* Default invocation adapter: emits SKILL.md with `mcp:` frontmatter that
|
|
15
|
+
* MCP-native agent harnesses parse to launch the server over stdio or
|
|
16
|
+
* connect to it over HTTP.
|
|
17
|
+
*
|
|
18
|
+
* Launch-shape resolution narrows on `ctx.mode` (per data-model.md §1):
|
|
19
|
+
*
|
|
20
|
+
* 1. **`mode: 'bundle'`** — the host bundle command flagged this skill as
|
|
21
|
+
* self-referential. Emits `command: npx` + `args: [-y, <packageName>]`
|
|
22
|
+
* (or the multi-bin `--package=<pkg> <bin>` form per FR-034).
|
|
23
|
+
* 2. **`mode: 'http'`** — emits a `{ url, headers? }` shape (no shell launch).
|
|
24
|
+
* 3. **`mode: 'stdio'`** — `ctx.launchCommand` is used verbatim.
|
|
25
|
+
*
|
|
26
|
+
* The renderer's invocation-adapter dispatch in `@skillit/core` guarantees
|
|
27
|
+
* `mode` is always one of these three arms, so the previous runtime
|
|
28
|
+
* `MISSING_LAUNCH_COMMAND` throw is no longer needed at the adapter level.
|
|
29
|
+
* An exhaustive `default` branch is kept for compile-time exhaustiveness.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* The adapter does NOT render its own body content — it calls `renderSkill`
|
|
33
|
+
* with `invocation: undefined` to dispatch through core's default synchronous
|
|
34
|
+
* path, then injects the structured frontmatter object via
|
|
35
|
+
* `additionalFrontmatter`. This guarantees parity with non-MCP skills and means
|
|
36
|
+
* future renderer features (Quick Reference enhancements, new sections) work
|
|
37
|
+
* out of the box for MCP skills too.
|
|
38
|
+
*/
|
|
39
|
+
export class McpProtocolAdapter {
|
|
40
|
+
target = 'mcp-protocol';
|
|
41
|
+
fingerprint;
|
|
42
|
+
constructor() {
|
|
43
|
+
this.fingerprint = {
|
|
44
|
+
adapter: '@skillit/target-mcp-protocol',
|
|
45
|
+
version: PACKAGE_VERSION
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Render an `ExtractedSkill` into a `RenderedSkill` carrying `mcp:` frontmatter.
|
|
50
|
+
*
|
|
51
|
+
* Narrows on `ctx.mode` to pick the launch shape — see the class-level
|
|
52
|
+
* docstring for the per-arm dialect.
|
|
53
|
+
*/
|
|
54
|
+
async render(skill, ctx) {
|
|
55
|
+
let launchCommand;
|
|
56
|
+
switch (ctx.mode) {
|
|
57
|
+
case 'bundle':
|
|
58
|
+
// Bundle mode: emit npx-by-name self-reference. When the host also
|
|
59
|
+
// passes binName (multi-bin packages, FR-034), use the explicit
|
|
60
|
+
// `--package=` form so npx invokes the right bin rather than the
|
|
61
|
+
// package's "directories.bin" or single-bin default.
|
|
62
|
+
launchCommand = ctx.binName
|
|
63
|
+
? { command: 'npx', args: ['-y', `--package=${ctx.packageName}`, ctx.binName] }
|
|
64
|
+
: { command: 'npx', args: ['-y', ctx.packageName] };
|
|
65
|
+
break;
|
|
66
|
+
case 'http':
|
|
67
|
+
// HTTP-extract mode: emit {url, headers} shape. No shell launch.
|
|
68
|
+
launchCommand = ctx.httpEndpoint.headers
|
|
69
|
+
? { url: ctx.httpEndpoint.url, headers: ctx.httpEndpoint.headers }
|
|
70
|
+
: { url: ctx.httpEndpoint.url };
|
|
71
|
+
break;
|
|
72
|
+
case 'stdio':
|
|
73
|
+
launchCommand = ctx.launchCommand;
|
|
74
|
+
break;
|
|
75
|
+
default: {
|
|
76
|
+
// Exhaustiveness: if a new arm is added to AdapterRenderContext
|
|
77
|
+
// without updating this switch, TypeScript flags `_exhaustive`'s
|
|
78
|
+
// type as non-`never` here.
|
|
79
|
+
const _exhaustive = ctx;
|
|
80
|
+
throw new Error(`McpProtocolAdapter.render: unknown ctx.mode (${String(_exhaustive)})`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const additionalFrontmatter = emitMcpFrontmatter(ctx.skillName, launchCommand);
|
|
84
|
+
// Delegate body rendering + references emission to core's default path.
|
|
85
|
+
// `invocation: undefined` dispatches the synchronous overload; `namePrefix`
|
|
86
|
+
// ensures core's toSkillName() yields the same skillName the host computed.
|
|
87
|
+
const baseRendered = renderSkill(skill, {
|
|
88
|
+
maxTokens: ctx.maxTokens,
|
|
89
|
+
additionalFrontmatter,
|
|
90
|
+
invocation: undefined,
|
|
91
|
+
namePrefix: ctx.skillName
|
|
92
|
+
});
|
|
93
|
+
return baseRendered;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAyB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,kBAAkB;IACpB,MAAM,GAAG,cAAuB,CAAC;IACjC,WAAW,CAAqB;IAEzC;QACE,IAAI,CAAC,WAAW,GAAG;YACjB,OAAO,EAAE,8BAA8B;YACvC,OAAO,EAAE,eAAe;SACzB,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,KAAqB,EAAE,GAAyB;QAC3D,IAAI,aAA+B,CAAC;QACpC,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,QAAQ;gBACX,mEAAmE;gBACnE,gEAAgE;gBAChE,iEAAiE;gBACjE,qDAAqD;gBACrD,aAAa,GAAG,GAAG,CAAC,OAAO;oBACzB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,aAAa,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC/E,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtD,MAAM;YACR,KAAK,MAAM;gBACT,iEAAiE;gBACjE,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO;oBACtC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE;oBAClE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;gBAClC,MAAM;YACR,KAAK,OAAO;gBACV,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;gBAClC,MAAM;YACR,OAAO,CAAC,CAAC,CAAC;gBACR,gEAAgE;gBAChE,iEAAiE;gBACjE,4BAA4B;gBAC5B,MAAM,WAAW,GAAU,GAAG,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gDAAgD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;QAED,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE/E,wEAAwE;QACxE,4EAA4E;QAC5E,4EAA4E;QAC5E,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE;YACtC,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,qBAAqB;YACrB,UAAU,EAAE,SAAS;YACrB,UAAU,EAAE,GAAG,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter package version — embedded into the `AdapterFingerprint`.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Kept in a separate module so `render.ts` doesn't need to import the
|
|
6
|
+
* default export of `index.ts` (which would create a small circular import).
|
|
7
|
+
* Bump this string whenever the adapter's output shape changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PACKAGE_VERSION = "0.1.0";
|
|
10
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter package version — embedded into the `AdapterFingerprint`.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Kept in a separate module so `render.ts` doesn't need to import the
|
|
6
|
+
* default export of `index.ts` (which would create a small circular import).
|
|
7
|
+
* Bump this string whenever the adapter's output shape changes.
|
|
8
|
+
*/
|
|
9
|
+
export const PACKAGE_VERSION = '0.1.0';
|
|
10
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillit/target-mcp-protocol",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Default invocation-target adapter for @skillit/mcp — emits mcp: frontmatter for MCP-native agent harnesses (OpenCode, Codex, Cursor)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent-skills",
|
|
7
|
+
"ai",
|
|
8
|
+
"mcp",
|
|
9
|
+
"model-context-protocol",
|
|
10
|
+
"skillit"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Pradeep Mouli",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/pradeepmouli/skillit.git",
|
|
17
|
+
"directory": "packages/target-mcp-protocol"
|
|
18
|
+
},
|
|
19
|
+
"funding": {
|
|
20
|
+
"type": "github",
|
|
21
|
+
"url": "https://github.com/sponsors/pradeepmouli"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"yaml": "^2.9.0",
|
|
38
|
+
"@skillit/core": "1.5.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^25.9.1",
|
|
42
|
+
"vitest": "^4.1.7",
|
|
43
|
+
"@skillit/mcp": "0.3.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@skillit/mcp": "0.3.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"type-check": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
}
|
|
53
|
+
}
|