@mentelm/mmcp-plugin-opencode2 0.0.0-stage → 0.0.2

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,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # MMCP OpenCode Plugin (v2)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Plugin for OpenCode v2. Auto-registers MMCP slices from a server as separate MCP servers on startup.
4
+
5
+ To use, put following in `opencode.json`:
6
+ ```json
7
+ {
8
+ "plugins": [
9
+ {
10
+ "package": "@mentelm/mmcp-plugin-opencode2@<version>",
11
+ "options": {
12
+ "url": "url-to-your-mmcp-server",
13
+ "sliceFetchTimeout": 2000
14
+ }
15
+ }
16
+ ]
17
+ }
18
+ ```
19
+ `url` - base URL on which mmcpServer was registered (GET on this URL should respond with list of Slices)
20
+ `sliceFetchTimeout` - controls timeout (milliseconds) on initial request that fetches list of Slices. Optional. Default = 1500.
21
+
22
+ **NOTE:**
23
+ This package is the OpenCode v2 port of [`@mentelm/mmcp-plugin-opencode`](../opencode), which targets OpenCode v1.
24
+ They are separate packages - V1 plugin implementations do not run in V2, so pick the one matching your OpenCode version.
25
+
26
+ ## Differences from the v1 plugin
27
+
28
+ Behaviour is the same: the plugin fetches the slice list once during setup and registers each slice as its own remote
29
+ MCP server. Only the OpenCode plugin API differs.
30
+
31
+ | v1 | v2 |
32
+ | --- | --- |
33
+ | exported plugin function returning `Hooks` | `Plugin.define({ id, setup })` |
34
+ | `plugin` config key with `[package, options]` tuple | `plugins` config key with `{ package, options }` object |
35
+ | options passed as the second function argument | `ctx.options` |
36
+ | `config` hook mutating `cfg.mcp` | `ctx.mcp.transform((editor) => editor.set(name, config))` |
37
+ | `McpRemoteConfig.timeout: number` | `Mcp.TimeoutConfig` with `startup` / `catalog` / `execution` |
38
+
39
+ v1's single `timeout` capped MCP discovery (`tools/list`), so the equivalent v2 field is `catalog`. `startup` and
40
+ `execution` keep their OpenCode defaults.
41
+
42
+ The plugin ID is `mentelm.mmcp`, which is also the prefix to use when [disabling it via config](https://opencode.ai/v2/docs/plugins/#control).
@@ -0,0 +1,2 @@
1
+ export declare function fetchMcpSlices(baseUrl: string, timeout: number): Promise<string[]>;
2
+ //# sourceMappingURL=fetch-slices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-slices.d.ts","sourceRoot":"","sources":["../src/fetch-slices.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBxF"}
@@ -0,0 +1,15 @@
1
+ export async function fetchMcpSlices(baseUrl, timeout) {
2
+ const headers = {
3
+ 'Accept': 'application/json',
4
+ 'User-Agent': 'MMCP-plugin-opencode2/1.0.0'
5
+ };
6
+ const response = await fetch(baseUrl, {
7
+ headers,
8
+ signal: AbortSignal.timeout(timeout)
9
+ });
10
+ if (!response.ok) {
11
+ throw new Error(`Could not fetch slices: HTTP ${String(response.status)} ${response.statusText}`);
12
+ }
13
+ return await response.json();
14
+ }
15
+ //# sourceMappingURL=fetch-slices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-slices.js","sourceRoot":"","sources":["../src/fetch-slices.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe,EAAE,OAAe;IACnE,MAAM,OAAO,GAA2B;QACtC,QAAQ,EAAE,kBAAkB;QAC5B,YAAY,EAAE,6BAA6B;KAC5C,CAAC;IAEF,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,OAAO,EAAE;QAC9C,OAAO;QACP,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;KACrC,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAc,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import plugin from './plugin.js';
2
+ export default plugin;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import plugin from './plugin.js';
2
+ export default plugin;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Mcp } from '@opencode/plugin';
2
+ export declare function mapToServerConfigs(baseUrl: string, sliceNames: string[]): Record<string, Mcp.ServerConfig>;
3
+ //# sourceMappingURL=map-to-server-configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-to-server-configs.d.ts","sourceRoot":"","sources":["../src/map-to-server-configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAY1G"}
@@ -0,0 +1,12 @@
1
+ export function mapToServerConfigs(baseUrl, sliceNames) {
2
+ const result = {};
3
+ sliceNames.forEach((sliceName) => {
4
+ result[sliceName] = ({
5
+ 'type': 'remote',
6
+ url: baseUrl + '/' + sliceName,
7
+ timeout: { catalog: 2500 }
8
+ });
9
+ });
10
+ return result;
11
+ }
12
+ //# sourceMappingURL=map-to-server-configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-to-server-configs.js","sourceRoot":"","sources":["../src/map-to-server-configs.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,UAAoB;IACtE,MAAM,MAAM,GAAqC,EAAE,CAAC;IAEpD,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;YACnB,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS;YAC9B,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC3B,CAAC,CAAA;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from '@opencode/plugin';
2
+ declare const plugin: Plugin.Plugin;
3
+ export default plugin;
4
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIpD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAmBpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,21 @@
1
+ import { fetchMcpSlices } from './fetch-slices.js';
2
+ import { mapToServerConfigs } from './map-to-server-configs.js';
3
+ const plugin = {
4
+ id: 'mentelm.mmcp',
5
+ async setup(ctx) {
6
+ const baseUrl = ctx.options['url'];
7
+ if (typeof baseUrl !== 'string' || baseUrl.length === 0) {
8
+ throw new Error('MMCP plugin configuration missing');
9
+ }
10
+ const sliceFetchTimeout = ctx.options['sliceFetchTimeout'] ?? 1500;
11
+ const slices = await fetchMcpSlices(baseUrl, sliceFetchTimeout);
12
+ const serverConfigs = mapToServerConfigs(baseUrl, slices);
13
+ await ctx.mcp.transform((editor) => {
14
+ Object.entries(serverConfigs).forEach(([name, config]) => {
15
+ editor.set(name, config);
16
+ });
17
+ });
18
+ }
19
+ };
20
+ export default plugin;
21
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,MAAM,GAAkB;IAC5B,EAAE,EAAE,cAAc;IAClB,KAAK,CAAC,KAAK,CAAC,GAAG;QACb,MAAM,OAAO,GAAY,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,iBAAiB,GAAY,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAwB,IAAI,IAAI,CAAC;QAEnG,MAAM,MAAM,GAAa,MAAM,cAAc,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAqC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAE5F,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACjC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;gBACvD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "@mentelm/mmcp-plugin-opencode2",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "devDependencies": {
6
+ "@opencode/plugin": "^2.0.22"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.json",
10
+ "test": "echo 'no tests for opencode2 plugin yet'",
11
+ "check-version": "bash ../../scripts/check-version.sh",
12
+ "publish": "yarn npm publish --access public --staged"
13
+ },
14
+ "files": [
15
+ "package.json",
16
+ "README.md",
17
+ "dist"
18
+ ],
19
+ "main": "dist/index.js",
20
+ "exports": {
21
+ ".": "./dist/index.js"
22
+ }
6
23
  }