@mirsella/context7-account-broker 0.4.1 → 0.4.3
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 +6 -2
- package/package.json +3 -3
- package/plugin/context7.ts +24 -6
- package/vendor/context7-account-broker +0 -0
package/README.md
CHANGED
|
@@ -47,11 +47,11 @@ Add the plugin to `opencode.json`:
|
|
|
47
47
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
|
-
"
|
|
50
|
+
"plugins": ["@mirsella/context7-account-broker"]
|
|
51
51
|
}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
The plugin registers `mcp.servers.context7-broker` and refuses to replace an existing entry. If you already configure the stdio command manually, you do not need the plugin. OpenCode V1.18.29 and later in the V1 series use `"plugin"` instead of `"plugins"`.
|
|
55
55
|
|
|
56
56
|
## Lifecycle
|
|
57
57
|
|
|
@@ -62,6 +62,8 @@ Clients using the same version and XDG configuration/cache directories share the
|
|
|
62
62
|
The `start` command remains available for direct HTTP clients and prints connection JSON. Keep that output private: it includes the broker token.
|
|
63
63
|
Startup makes no Context7 requests. Context7 is contacted only for tool calls and the explicit `status` command.
|
|
64
64
|
|
|
65
|
+
The running broker reads `accounts.json` for each tool call, including after a call waits for an upstream slot. Adding, removing, or rotating a key does not require restarting. Requests already sent upstream may still finish. If the file is invalid or unreadable, new calls report the error instead of using stale credentials.
|
|
66
|
+
|
|
65
67
|
## Commands
|
|
66
68
|
|
|
67
69
|
```text
|
|
@@ -90,6 +92,8 @@ The npm package contains a static `x86_64-unknown-linux-musl` binary. Each activ
|
|
|
90
92
|
|
|
91
93
|
The broker provides the canonical `resolve-library-id` and `query-docs` tools. It routes toward account affinity and lower quota use, rotates unknown quota fairly, fails over account-specific `401`, `402`, `403`, and `429` responses, and caps shared endpoint failures at two attempts. Successful results use an account-partitioned disk cache. Identical typed requests share one cancellation-safe in-flight producer.
|
|
92
94
|
|
|
95
|
+
An upstream attempt has 10 seconds. Queueing, retries, and failover share a 25-second broker deadline, leaving time to return the result through the stdio proxy before the recommended 30-second client timeout.
|
|
96
|
+
|
|
93
97
|
Default private state:
|
|
94
98
|
|
|
95
99
|
- Accounts: `${XDG_CONFIG_HOME:-$HOME/.config}/context7-account-broker/accounts.json`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirsella/context7-account-broker",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Shared multi-account Context7 MCP for Linux x64",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"cpu": [
|
|
41
41
|
"x64"
|
|
42
42
|
],
|
|
43
|
-
"packageManager": "pnpm@
|
|
43
|
+
"packageManager": "pnpm@12.25.1",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@opencode
|
|
45
|
+
"@opencode/plugin": "2.4.3"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/plugin/context7.ts
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
import type { Plugin
|
|
1
|
+
import type { Plugin } from "@opencode/plugin";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
4
|
const BINARY = fileURLToPath(new URL("../vendor/context7-account-broker", import.meta.url));
|
|
5
5
|
const MCP_NAME = "context7-broker";
|
|
6
|
+
const PLUGIN_ID = "@mirsella/context7-account-broker";
|
|
7
|
+
const TIMEOUT_MS = 30_000;
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
config: async (config) => {
|
|
9
|
+
const legacyServer = async () => ({
|
|
10
|
+
config: async (config: { mcp?: Record<string, unknown> }) => {
|
|
9
11
|
if (config.mcp?.[MCP_NAME] !== undefined) {
|
|
10
|
-
throw new Error(
|
|
12
|
+
throw new Error(`${PLUGIN_ID} cannot replace the existing mcp.${MCP_NAME} configuration`);
|
|
11
13
|
}
|
|
12
14
|
config.mcp ??= {};
|
|
13
15
|
config.mcp[MCP_NAME] = {
|
|
14
16
|
type: "local",
|
|
15
17
|
command: [BINARY, "mcp"],
|
|
16
18
|
enabled: true,
|
|
17
|
-
timeout:
|
|
19
|
+
timeout: TIMEOUT_MS,
|
|
18
20
|
};
|
|
19
21
|
},
|
|
20
22
|
});
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
// Plugin.define returns this shape unchanged; keep the SDK out of the shipped runtime.
|
|
25
|
+
export default {
|
|
26
|
+
id: PLUGIN_ID,
|
|
27
|
+
async setup(ctx) {
|
|
28
|
+
await ctx.mcp.transform((editor) => {
|
|
29
|
+
if (editor.get(MCP_NAME) !== undefined) {
|
|
30
|
+
throw new Error(`${PLUGIN_ID} cannot replace the existing mcp.servers.${MCP_NAME} configuration`);
|
|
31
|
+
}
|
|
32
|
+
editor.set(MCP_NAME, {
|
|
33
|
+
type: "local",
|
|
34
|
+
command: [BINARY, "mcp"],
|
|
35
|
+
timeout: { execution: TIMEOUT_MS },
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
server: legacyServer,
|
|
40
|
+
} satisfies ReturnType<typeof Plugin.define> & { server: typeof legacyServer };
|
|
Binary file
|