@nite07/websearch-mcp 0.1.4 → 0.2.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/README.md +46 -0
- package/README.zh.md +38 -0
- package/dist/live.d.ts +21 -0
- package/dist/live.js +52 -0
- package/dist/main.js +217 -37
- package/dist/sdk.d.ts +21 -0
- package/dist/sdk.js +88 -0
- package/dist/tools.d.ts +2 -1
- package/dist/tools.js +20 -4
- package/dist/ui/embedded.d.ts +20 -0
- package/dist/ui/embedded.js +14 -0
- package/dist/ui/page.d.ts +2 -0
- package/dist/ui/page.html +694 -0
- package/dist/ui/page.js +15 -0
- package/dist/ui/server.d.ts +21 -0
- package/dist/ui/server.js +243 -0
- package/dist/ui/session.d.ts +38 -0
- package/dist/ui/session.js +111 -0
- package/dist/ui/state.d.ts +62 -0
- package/dist/ui/state.js +256 -0
- package/dist/ui/token.d.ts +23 -0
- package/dist/ui/token.js +23 -0
- package/package.json +3 -2
- package/dist/protocol.d.ts +0 -19
- package/dist/protocol.js +0 -125
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server can serve the page itself. There is no second process to install, supervise or
|
|
3
|
+
* mount: the port is an environment variable on the same process that answers the MCP tools, which
|
|
4
|
+
* is also the only process that already has the configuration in memory.
|
|
5
|
+
*/
|
|
6
|
+
export interface EmbeddedTarget {
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
}
|
|
10
|
+
export interface EmbeddedDecision {
|
|
11
|
+
target?: EmbeddedTarget;
|
|
12
|
+
/** Why the page stays off, when the variables are set but unusable. */
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EmbeddedInput {
|
|
16
|
+
port?: string;
|
|
17
|
+
host?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveEmbeddedUi(input: EmbeddedInput): EmbeddedDecision;
|
|
20
|
+
export declare const embeddedFromEnv: (env?: NodeJS.ProcessEnv) => EmbeddedDecision;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function resolveEmbeddedUi(input) {
|
|
2
|
+
const raw = input.port?.trim();
|
|
3
|
+
if (!raw)
|
|
4
|
+
return {};
|
|
5
|
+
const port = Number(raw);
|
|
6
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
7
|
+
return { error: `${raw} is not a port number between 0 and 65535` };
|
|
8
|
+
}
|
|
9
|
+
return { target: { host: input.host?.trim() || '127.0.0.1', port } };
|
|
10
|
+
}
|
|
11
|
+
export const embeddedFromEnv = (env = process.env) => resolveEmbeddedUi({
|
|
12
|
+
...(env.WEBSEARCH_MCP_UI_PORT === undefined ? {} : { port: env.WEBSEARCH_MCP_UI_PORT }),
|
|
13
|
+
...(env.WEBSEARCH_MCP_UI_HOST === undefined ? {} : { host: env.WEBSEARCH_MCP_UI_HOST }),
|
|
14
|
+
});
|