@reneturcios/chelseaguide 0.0.0-stage → 0.1.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 +79 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/forward.d.ts +76 -0
- package/dist/forward.js +513 -0
- package/dist/forward.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +33 -0
- package/dist/mcp.js +58 -0
- package/dist/mcp.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -6
- package/server.json +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rene Turcios
|
|
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
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# chelseaguide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Curated Chelsea places and guides: list, search, compare and nearby lookup. chelseaguide is a local forwarding client for the hosted MCP service at knowchelsea.com: it answers `tools/list` on your own machine from the captured tool definitions and forwards every call to the service, returning the answers exactly as they come back.
|
|
4
|
+
|
|
5
|
+
## The tools
|
|
6
|
+
|
|
7
|
+
- **`list_places`** — Andrew's curated places in Chelsea, optionally filtered by category, use-case tag or featured picks.
|
|
8
|
+
- **`get_place`** — Full editorial record for one Chelsea place by slug, including Andrew's description and the public /place URL. Required: `slug`.
|
|
9
|
+
- **`nearby_places`** — Nearest curated Chelsea places to a WGS84 coordinate supplied in the request, with distance in metres. Required: `latitude`, `longitude`.
|
|
10
|
+
- **`search_places`** — Filter Andrew's Chelsea places by category, sub-zone, tags, featured picks or text, ranked like https://knowchelsea.com/best/{category}.
|
|
11
|
+
- **`compare_places`** — Side-by-side sourced records for 2 to 4 Chelsea places by slug, with the tags they share. Required: `slugs`.
|
|
12
|
+
- **`list_guides`** — Andrew's published Chelsea themed guides (https://knowchelsea.com/guides/{slug}), with sourced titles, summaries and place counts.
|
|
13
|
+
- **`get_guide`** — One published Chelsea guide by slug: Andrew's introduction and its ranked places, every field sourced. Required: `slug`.
|
|
14
|
+
|
|
15
|
+
## Install and run
|
|
16
|
+
|
|
17
|
+
As an MCP server via npm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx -y @reneturcios/chelseaguide mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
MCP client configuration:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"chelseaguide": {
|
|
29
|
+
"command": "npx",
|
|
30
|
+
"args": ["-y", "@reneturcios/chelseaguide", "mcp"]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
As a container:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
docker run -i ghcr.io/cloudcorprecords/chelseaguide
|
|
40
|
+
docker run --rm ghcr.io/cloudcorprecords/chelseaguide list_places '<json-args>'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## CLI
|
|
44
|
+
|
|
45
|
+
One binary serves both the command line and the MCP server. Each tool is a subcommand taking a single JSON string with that tool's arguments:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
chelseaguide list_places '{}'
|
|
49
|
+
chelseaguide get_place '{"slug":"example-slug"}'
|
|
50
|
+
chelseaguide --version
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Exit codes: `0` when the forwarded call succeeds, `1` when the upstream result is an error, and `2` for usage problems such as an unknown subcommand or a malformed JSON argument.
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
- `KNOWCHELSEA_MCP_URL` — Overrides the upstream endpoint. The default is the pinned hosted endpoint, `https://knowchelsea.com/mcp`. (The override variable is a reconstruction added by this rebuild.)
|
|
58
|
+
|
|
59
|
+
The upstream registry record declares no headers on its remote, so chelseaguide sends no authentication header of any kind — the calls are keyless.
|
|
60
|
+
|
|
61
|
+
Upstream failures — a JSON-RPC error from the service, a non-2xx response, an unreadable body, or a request that fails outright — are reported to the caller as an error result whose text starts with `chelseaguide error:`.
|
|
62
|
+
|
|
63
|
+
## How forwarding works
|
|
64
|
+
|
|
65
|
+
The first forwarded call opens a session: an `initialize` request (protocol version `2025-03-26`), followed by a `notifications/initialized` notification, then the `tools/call` itself. If the service answers the initialize request with an `Mcp-Session-Id` header, that value is carried on every later request, and the open session is reused for the rest of the process. Replies are accepted either as plain JSON or as server-sent events. Successful results pass through verbatim, including any `isError` flag and any extra fields the service includes. The full captured surface is 7 tools.
|
|
66
|
+
|
|
67
|
+
## Development
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm install
|
|
71
|
+
npm run build # tsc -> dist/ (dist/cli.js is the bin)
|
|
72
|
+
npm test # tsx --test test/*.test.ts — stubbed upstream, no network
|
|
73
|
+
npm run dev # run the CLI from source
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The test suite checks the served tool list against the captured fixture, exercises the session handshake and its reuse, asserts that no `Authorization` header is sent under any environment, and verifies that arguments go upstream untouched and results come back untouched.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT — see `LICENSE`. Copyright (c) 2026 Rene Turcios.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* chelseaguide CLI.
|
|
4
|
+
*
|
|
5
|
+
* chelseaguide <tool> '<json-args>'
|
|
6
|
+
* chelseaguide mcp
|
|
7
|
+
* chelseaguide --version
|
|
8
|
+
*
|
|
9
|
+
* <tool> is one of the 7 captured forwarded tools.
|
|
10
|
+
* Each tool subcommand takes a single JSON argument string
|
|
11
|
+
* holding that tool's arguments, forwards the call the
|
|
12
|
+
* same way the MCP path does, and prints the forwarded
|
|
13
|
+
* result content. Exit codes: 0 success, 1 on an
|
|
14
|
+
* isError result, 2 usage error.
|
|
15
|
+
*/
|
|
16
|
+
import { callTool, TOOL_NAMES, VERSION } from "./forward.js";
|
|
17
|
+
function usage() {
|
|
18
|
+
console.error(`Usage:
|
|
19
|
+
chelseaguide <tool> '<json-args>' one of: ${TOOL_NAMES.join(", ")}
|
|
20
|
+
chelseaguide mcp
|
|
21
|
+
chelseaguide --version`);
|
|
22
|
+
process.exit(2);
|
|
23
|
+
}
|
|
24
|
+
function firstText(result) {
|
|
25
|
+
const content = result.content;
|
|
26
|
+
if (Array.isArray(content)) {
|
|
27
|
+
for (const item of content) {
|
|
28
|
+
if (item !== null &&
|
|
29
|
+
typeof item === "object" &&
|
|
30
|
+
item.type === "text" &&
|
|
31
|
+
typeof item.text === "string") {
|
|
32
|
+
return item.text;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return typeof content === "string" ? content : JSON.stringify(content);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
40
|
+
if (cmd === "--version" || cmd === "-v") {
|
|
41
|
+
console.log(VERSION);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (cmd === "mcp") {
|
|
45
|
+
if (rest.length !== 0)
|
|
46
|
+
usage();
|
|
47
|
+
const { startMcpServer } = await import("./mcp.js");
|
|
48
|
+
await startMcpServer();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!TOOL_NAMES.includes(cmd ?? ""))
|
|
52
|
+
usage();
|
|
53
|
+
if (rest.length > 1)
|
|
54
|
+
usage();
|
|
55
|
+
let args = {};
|
|
56
|
+
if (rest.length === 1) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(rest[0]);
|
|
59
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
60
|
+
usage();
|
|
61
|
+
}
|
|
62
|
+
args = parsed;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
console.error("error: argument must be a JSON object string");
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const result = await callTool(cmd, args);
|
|
70
|
+
if (result.isError) {
|
|
71
|
+
console.error(`error: ${firstText(result)}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
console.log(typeof result.content === "string"
|
|
75
|
+
? result.content
|
|
76
|
+
: JSON.stringify(result.content, null, 2));
|
|
77
|
+
}
|
|
78
|
+
void main();
|
|
79
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG7D,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CAAC;kDACkC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;yBAE9C,CAAC,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAAC,MAAkB;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,IACE,IAAI,KAAK,IAAI;gBACb,OAAO,IAAI,KAAK,QAAQ;gBACvB,IAA2B,CAAC,IAAI,KAAK,MAAM;gBAC5C,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,EACrD,CAAC;gBACD,OAAQ,IAAyB,CAAC,IAAI,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7C,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,C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CAAC,GAAG,CACT,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO;QAChB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chelseaguide core: a forwarding client for the hosted
|
|
3
|
+
* MCP server at https://knowchelsea.com/mcp.
|
|
4
|
+
*
|
|
5
|
+
* No data of the upstream service lives on this machine.
|
|
6
|
+
* tools/list is answered from the literal definitions
|
|
7
|
+
* below, which reproduce a live capture of the upstream
|
|
8
|
+
* server word for word (name, title where captured,
|
|
9
|
+
* description and inputSchema exactly as captured). A
|
|
10
|
+
* tools/call travels upstream over a streamable-HTTP
|
|
11
|
+
* JSON-RPC session: an initialize POST, a
|
|
12
|
+
* notifications/initialized POST, then the tools/call
|
|
13
|
+
* POST, carrying the Mcp-Session-Id response header on
|
|
14
|
+
* later requests when the upstream issues one. The
|
|
15
|
+
* session opens lazily on the first forwarded call and
|
|
16
|
+
* is reused for the client's lifetime.
|
|
17
|
+
*
|
|
18
|
+
* The endpoint is pinned to https://knowchelsea.com/mcp
|
|
19
|
+
* and may be replaced with the KNOWCHELSEA_MCP_URL
|
|
20
|
+
* environment variable (that override is a labelled
|
|
21
|
+
* reconstruction). The registry record declares NO
|
|
22
|
+
* headers on the remote: no auth header is ever sent,
|
|
23
|
+
* under any environment.
|
|
24
|
+
*
|
|
25
|
+
* A successful upstream result is returned exactly as
|
|
26
|
+
* received, isError flag and extra fields included.
|
|
27
|
+
* Failures — an upstream JSON-RPC error, a non-2xx
|
|
28
|
+
* status, a body that cannot be parsed, or a fetch
|
|
29
|
+
* that throws or times out — become an isError result
|
|
30
|
+
* whose text begins with `chelseaguide error:` (that
|
|
31
|
+
* rendering is a labelled reconstruction). Replies may
|
|
32
|
+
* be plain JSON or SSE (`data:` lines); the JSON-RPC
|
|
33
|
+
* message whose id matches the request wins.
|
|
34
|
+
*/
|
|
35
|
+
import type { ForwardDeps, ToolArgs, ToolDef, ToolResult } from "./types.js";
|
|
36
|
+
export declare const VERSION = "0.1.0";
|
|
37
|
+
export declare const DEFAULT_ENDPOINT_URL = "https://knowchelsea.com/mcp";
|
|
38
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
39
|
+
export declare const PROTOCOL_VERSION = "2025-03-26";
|
|
40
|
+
export declare const TOOL_DEFS: ToolDef[];
|
|
41
|
+
export declare const TOOL_NAMES: string[];
|
|
42
|
+
/** Whether `name` belongs to the captured surface. */
|
|
43
|
+
export declare function isKnownTool(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Read a JSON-RPC response body, tolerating SSE framing.
|
|
46
|
+
* Returns the message whose id matches `expectedId` when
|
|
47
|
+
* present, otherwise the last parseable message, otherwise
|
|
48
|
+
* null when nothing in the body parses.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseRpcBody(text: string, expectedId?: number): Record<string, unknown> | null;
|
|
51
|
+
/**
|
|
52
|
+
* A forwarding client holding a single upstream session,
|
|
53
|
+
* opened lazily on first use and reused from then on
|
|
54
|
+
* (for the process lifetime in the MCP server, or for a
|
|
55
|
+
* single invocation in the CLI).
|
|
56
|
+
*/
|
|
57
|
+
export declare class ChelseaguideClient {
|
|
58
|
+
private readonly deps;
|
|
59
|
+
private sessionId;
|
|
60
|
+
private ready;
|
|
61
|
+
private sessionPromise;
|
|
62
|
+
private idCounter;
|
|
63
|
+
constructor(deps?: ForwardDeps);
|
|
64
|
+
private fetchFn;
|
|
65
|
+
private endpointUrl;
|
|
66
|
+
private timeoutMs;
|
|
67
|
+
private nextId;
|
|
68
|
+
private post;
|
|
69
|
+
private ensureSession;
|
|
70
|
+
/** Forward one tool call; upstream failures come back as isError results. */
|
|
71
|
+
callTool(name: string, args: ToolArgs): Promise<ToolResult>;
|
|
72
|
+
}
|
|
73
|
+
/** Build a forwarding client; tests inject a fake fetch and env through deps. */
|
|
74
|
+
export declare function createClient(deps?: ForwardDeps): ChelseaguideClient;
|
|
75
|
+
/** One-shot helper: a fresh client for a single call (the CLI path). */
|
|
76
|
+
export declare function callTool(name: string, args: ToolArgs, deps?: ForwardDeps): Promise<ToolResult>;
|
package/dist/forward.js
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
export const VERSION = "0.1.0";
|
|
2
|
+
export const DEFAULT_ENDPOINT_URL = "https://knowchelsea.com/mcp";
|
|
3
|
+
export const DEFAULT_TIMEOUT_MS = 30000;
|
|
4
|
+
export const PROTOCOL_VERSION = "2025-03-26";
|
|
5
|
+
/* ------------------------------------------------------------------ */
|
|
6
|
+
/* Tool definitions (tools/list literals, verbatim from the live */
|
|
7
|
+
/* capture in harness/fixtures/knowchelsea-tools-original.json; */
|
|
8
|
+
/* generated programmatically by parsing and re-serialising the */
|
|
9
|
+
/* fixture JSON, never retyped) */
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
export const TOOL_DEFS = [
|
|
12
|
+
{
|
|
13
|
+
"name": "list_places",
|
|
14
|
+
"title": "List Chelsea places",
|
|
15
|
+
"description": "Andrew's curated places in Chelsea, optionally filtered by category, use-case tag or featured picks. Each result links to its https://knowchelsea.com/place/{slug} page; ranked pages live at https://knowchelsea.com/best/{category}.",
|
|
16
|
+
"inputSchema": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"properties": {
|
|
20
|
+
"category": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": [
|
|
23
|
+
"coffee",
|
|
24
|
+
"bakery",
|
|
25
|
+
"restaurant",
|
|
26
|
+
"pub",
|
|
27
|
+
"park",
|
|
28
|
+
"shop",
|
|
29
|
+
"gym",
|
|
30
|
+
"school",
|
|
31
|
+
"health",
|
|
32
|
+
"transport",
|
|
33
|
+
"other"
|
|
34
|
+
],
|
|
35
|
+
"description": "Place category, for example coffee or restaurant"
|
|
36
|
+
},
|
|
37
|
+
"tag": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": [
|
|
40
|
+
"date-night",
|
|
41
|
+
"rainy-day",
|
|
42
|
+
"with-kids",
|
|
43
|
+
"outdoor-seating",
|
|
44
|
+
"dog-friendly",
|
|
45
|
+
"work-from",
|
|
46
|
+
"sunday-morning",
|
|
47
|
+
"quick-bite",
|
|
48
|
+
"special-occasion",
|
|
49
|
+
"budget",
|
|
50
|
+
"brunch",
|
|
51
|
+
"late-night",
|
|
52
|
+
"historic",
|
|
53
|
+
"hidden-gem",
|
|
54
|
+
"view",
|
|
55
|
+
"live-music",
|
|
56
|
+
"cosy",
|
|
57
|
+
"healthy"
|
|
58
|
+
],
|
|
59
|
+
"description": "Use-case tag, for example brunch or with-kids"
|
|
60
|
+
},
|
|
61
|
+
"featured": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "When true, only return featured picks"
|
|
64
|
+
},
|
|
65
|
+
"limit": {
|
|
66
|
+
"type": "integer",
|
|
67
|
+
"minimum": 1,
|
|
68
|
+
"maximum": 50,
|
|
69
|
+
"description": "Max places to return (default 25)"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "get_place",
|
|
76
|
+
"title": "Get a Chelsea place",
|
|
77
|
+
"description": "Full editorial record for one Chelsea place by slug, including Andrew's description and the public /place URL.",
|
|
78
|
+
"inputSchema": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"required": [
|
|
82
|
+
"slug"
|
|
83
|
+
],
|
|
84
|
+
"properties": {
|
|
85
|
+
"slug": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"description": "URL slug, for example artisan-coffee"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "nearby_places",
|
|
94
|
+
"title": "Find nearby Chelsea places",
|
|
95
|
+
"description": "Nearest curated Chelsea places to a WGS84 coordinate supplied in the request, with distance in metres.",
|
|
96
|
+
"inputSchema": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": false,
|
|
99
|
+
"required": [
|
|
100
|
+
"latitude",
|
|
101
|
+
"longitude"
|
|
102
|
+
],
|
|
103
|
+
"properties": {
|
|
104
|
+
"latitude": {
|
|
105
|
+
"type": "number",
|
|
106
|
+
"minimum": -90,
|
|
107
|
+
"maximum": 90
|
|
108
|
+
},
|
|
109
|
+
"longitude": {
|
|
110
|
+
"type": "number",
|
|
111
|
+
"minimum": -180,
|
|
112
|
+
"maximum": 180
|
|
113
|
+
},
|
|
114
|
+
"radius": {
|
|
115
|
+
"type": "integer",
|
|
116
|
+
"minimum": 1,
|
|
117
|
+
"maximum": 5000,
|
|
118
|
+
"description": "Search radius in metres (default 500)"
|
|
119
|
+
},
|
|
120
|
+
"limit": {
|
|
121
|
+
"type": "integer",
|
|
122
|
+
"minimum": 1,
|
|
123
|
+
"maximum": 50,
|
|
124
|
+
"description": "Max places to return (default 10)"
|
|
125
|
+
},
|
|
126
|
+
"category": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"enum": [
|
|
129
|
+
"coffee",
|
|
130
|
+
"bakery",
|
|
131
|
+
"restaurant",
|
|
132
|
+
"pub",
|
|
133
|
+
"park",
|
|
134
|
+
"shop",
|
|
135
|
+
"gym",
|
|
136
|
+
"school",
|
|
137
|
+
"health",
|
|
138
|
+
"transport",
|
|
139
|
+
"other"
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "search_places",
|
|
147
|
+
"title": "Search Chelsea places",
|
|
148
|
+
"description": "Filter Andrew's Chelsea places by category, sub-zone, tags, featured picks or text, ranked like https://knowchelsea.com/best/{category}. Every field carries its source; addresses, coordinates, hours, websites and photos are not included, so follow each place url for them. open_now only matches owner-supplied or official-site hours, and none are recorded yet.",
|
|
149
|
+
"inputSchema": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"additionalProperties": false,
|
|
152
|
+
"properties": {
|
|
153
|
+
"category": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"enum": [
|
|
156
|
+
"coffee",
|
|
157
|
+
"bakery",
|
|
158
|
+
"restaurant",
|
|
159
|
+
"pub",
|
|
160
|
+
"park",
|
|
161
|
+
"shop",
|
|
162
|
+
"gym",
|
|
163
|
+
"school",
|
|
164
|
+
"health",
|
|
165
|
+
"transport",
|
|
166
|
+
"other"
|
|
167
|
+
],
|
|
168
|
+
"description": "Place category, for example coffee or restaurant"
|
|
169
|
+
},
|
|
170
|
+
"sub_zone": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"enum": [
|
|
173
|
+
"sloane-square",
|
|
174
|
+
"kings-road",
|
|
175
|
+
"worlds-end"
|
|
176
|
+
],
|
|
177
|
+
"description": "Part of Chelsea"
|
|
178
|
+
},
|
|
179
|
+
"tags": {
|
|
180
|
+
"type": "array",
|
|
181
|
+
"items": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"enum": [
|
|
184
|
+
"date-night",
|
|
185
|
+
"rainy-day",
|
|
186
|
+
"with-kids",
|
|
187
|
+
"outdoor-seating",
|
|
188
|
+
"dog-friendly",
|
|
189
|
+
"work-from",
|
|
190
|
+
"sunday-morning",
|
|
191
|
+
"quick-bite",
|
|
192
|
+
"special-occasion",
|
|
193
|
+
"budget",
|
|
194
|
+
"brunch",
|
|
195
|
+
"late-night",
|
|
196
|
+
"historic",
|
|
197
|
+
"hidden-gem",
|
|
198
|
+
"view",
|
|
199
|
+
"live-music",
|
|
200
|
+
"cosy",
|
|
201
|
+
"healthy"
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
"description": "Use-case tags; a place must carry every tag given"
|
|
205
|
+
},
|
|
206
|
+
"featured": {
|
|
207
|
+
"type": "boolean",
|
|
208
|
+
"description": "When true, only return featured picks"
|
|
209
|
+
},
|
|
210
|
+
"query": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"minLength": 1,
|
|
213
|
+
"maxLength": 100,
|
|
214
|
+
"description": "Text matched against names and Andrew's descriptions and tips"
|
|
215
|
+
},
|
|
216
|
+
"open_now": {
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"description": "When true, only places open now by owner-supplied or official-site hours"
|
|
219
|
+
},
|
|
220
|
+
"limit": {
|
|
221
|
+
"type": "integer",
|
|
222
|
+
"minimum": 1,
|
|
223
|
+
"maximum": 50,
|
|
224
|
+
"description": "Max places to return (default 25)"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"name": "compare_places",
|
|
231
|
+
"title": "Compare Chelsea places",
|
|
232
|
+
"description": "Side-by-side sourced records for 2 to 4 Chelsea places by slug, with the tags they share.",
|
|
233
|
+
"inputSchema": {
|
|
234
|
+
"type": "object",
|
|
235
|
+
"additionalProperties": false,
|
|
236
|
+
"required": [
|
|
237
|
+
"slugs"
|
|
238
|
+
],
|
|
239
|
+
"properties": {
|
|
240
|
+
"slugs": {
|
|
241
|
+
"type": "array",
|
|
242
|
+
"items": {
|
|
243
|
+
"type": "string"
|
|
244
|
+
},
|
|
245
|
+
"minItems": 2,
|
|
246
|
+
"maxItems": 4,
|
|
247
|
+
"uniqueItems": true,
|
|
248
|
+
"description": "Distinct place slugs, for example [\"artisan-coffee\", \"the-harwood-arms\"]"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"name": "list_guides",
|
|
255
|
+
"title": "List Chelsea guides",
|
|
256
|
+
"description": "Andrew's published Chelsea themed guides (https://knowchelsea.com/guides/{slug}), with sourced titles, summaries and place counts.",
|
|
257
|
+
"inputSchema": {
|
|
258
|
+
"type": "object",
|
|
259
|
+
"additionalProperties": false,
|
|
260
|
+
"properties": {}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "get_guide",
|
|
265
|
+
"title": "Get a Chelsea guide",
|
|
266
|
+
"description": "One published Chelsea guide by slug: Andrew's introduction and its ranked places, every field sourced.",
|
|
267
|
+
"inputSchema": {
|
|
268
|
+
"type": "object",
|
|
269
|
+
"additionalProperties": false,
|
|
270
|
+
"required": [
|
|
271
|
+
"slug"
|
|
272
|
+
],
|
|
273
|
+
"properties": {
|
|
274
|
+
"slug": {
|
|
275
|
+
"type": "string",
|
|
276
|
+
"description": "Guide slug from list_guides, for example brunch"
|
|
277
|
+
},
|
|
278
|
+
"limit": {
|
|
279
|
+
"type": "integer",
|
|
280
|
+
"minimum": 1,
|
|
281
|
+
"maximum": 50,
|
|
282
|
+
"description": "Max places to return (default 25)"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
export const TOOL_NAMES = TOOL_DEFS.map((t) => t.name);
|
|
289
|
+
/** Whether `name` belongs to the captured surface. */
|
|
290
|
+
export function isKnownTool(name) {
|
|
291
|
+
return TOOL_NAMES.includes(name);
|
|
292
|
+
}
|
|
293
|
+
/* ------------------------------------------------------------------ */
|
|
294
|
+
/* Forwarding client */
|
|
295
|
+
/* ------------------------------------------------------------------ */
|
|
296
|
+
function errorResult(detail) {
|
|
297
|
+
return {
|
|
298
|
+
content: [{ type: "text", text: `chelseaguide error: ${detail}` }],
|
|
299
|
+
isError: true,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function rpcErrorMessage(error) {
|
|
303
|
+
if (error !== null && typeof error === "object") {
|
|
304
|
+
const message = error.message;
|
|
305
|
+
if (typeof message === "string" && message !== "")
|
|
306
|
+
return message;
|
|
307
|
+
return JSON.stringify(error);
|
|
308
|
+
}
|
|
309
|
+
return String(error);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Read a JSON-RPC response body, tolerating SSE framing.
|
|
313
|
+
* Returns the message whose id matches `expectedId` when
|
|
314
|
+
* present, otherwise the last parseable message, otherwise
|
|
315
|
+
* null when nothing in the body parses.
|
|
316
|
+
*/
|
|
317
|
+
export function parseRpcBody(text, expectedId) {
|
|
318
|
+
const trimmed = text.trim();
|
|
319
|
+
if (trimmed === "")
|
|
320
|
+
return null;
|
|
321
|
+
const candidates = [];
|
|
322
|
+
const tryPush = (payload) => {
|
|
323
|
+
try {
|
|
324
|
+
const parsed = JSON.parse(payload);
|
|
325
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
326
|
+
candidates.push(parsed);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
// Not a JSON payload; skip this candidate.
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
if (trimmed.includes("data:")) {
|
|
334
|
+
for (const line of trimmed.split("\n")) {
|
|
335
|
+
const t = line.trim();
|
|
336
|
+
if (!t.startsWith("data:"))
|
|
337
|
+
continue;
|
|
338
|
+
const payload = t.slice("data:".length).trim();
|
|
339
|
+
if (payload !== "" && payload !== "[DONE]")
|
|
340
|
+
tryPush(payload);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
tryPush(trimmed);
|
|
345
|
+
}
|
|
346
|
+
if (candidates.length === 0)
|
|
347
|
+
return null;
|
|
348
|
+
if (expectedId !== undefined) {
|
|
349
|
+
const match = candidates.find((c) => c.id === expectedId);
|
|
350
|
+
if (match !== undefined)
|
|
351
|
+
return match;
|
|
352
|
+
}
|
|
353
|
+
return candidates[candidates.length - 1];
|
|
354
|
+
}
|
|
355
|
+
async function defaultFetch(url, init) {
|
|
356
|
+
return fetch(url, init);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* A forwarding client holding a single upstream session,
|
|
360
|
+
* opened lazily on first use and reused from then on
|
|
361
|
+
* (for the process lifetime in the MCP server, or for a
|
|
362
|
+
* single invocation in the CLI).
|
|
363
|
+
*/
|
|
364
|
+
export class ChelseaguideClient {
|
|
365
|
+
deps;
|
|
366
|
+
sessionId = null;
|
|
367
|
+
ready = false;
|
|
368
|
+
sessionPromise = null;
|
|
369
|
+
idCounter = 0;
|
|
370
|
+
constructor(deps = {}) {
|
|
371
|
+
this.deps = deps;
|
|
372
|
+
}
|
|
373
|
+
fetchFn() {
|
|
374
|
+
return this.deps.fetchFn ?? defaultFetch;
|
|
375
|
+
}
|
|
376
|
+
endpointUrl() {
|
|
377
|
+
if (this.deps.url && this.deps.url.trim() !== "")
|
|
378
|
+
return this.deps.url.trim();
|
|
379
|
+
const raw = (this.deps.env ?? process.env).KNOWCHELSEA_MCP_URL;
|
|
380
|
+
if (raw && raw.trim() !== "")
|
|
381
|
+
return raw.trim();
|
|
382
|
+
return DEFAULT_ENDPOINT_URL;
|
|
383
|
+
}
|
|
384
|
+
timeoutMs() {
|
|
385
|
+
if (typeof this.deps.timeoutMs === "number" && this.deps.timeoutMs > 0) {
|
|
386
|
+
return this.deps.timeoutMs;
|
|
387
|
+
}
|
|
388
|
+
return DEFAULT_TIMEOUT_MS;
|
|
389
|
+
}
|
|
390
|
+
nextId() {
|
|
391
|
+
this.idCounter += 1;
|
|
392
|
+
return this.idCounter;
|
|
393
|
+
}
|
|
394
|
+
async post(body, withSession) {
|
|
395
|
+
// The registry record declares NO headers on the remote:
|
|
396
|
+
// no Authorization (or any other auth) header is ever sent.
|
|
397
|
+
const headers = {
|
|
398
|
+
"Content-Type": "application/json",
|
|
399
|
+
Accept: "application/json, text/event-stream",
|
|
400
|
+
};
|
|
401
|
+
if (withSession && this.sessionId !== null) {
|
|
402
|
+
headers["Mcp-Session-Id"] = this.sessionId;
|
|
403
|
+
}
|
|
404
|
+
const controller = new AbortController();
|
|
405
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs());
|
|
406
|
+
try {
|
|
407
|
+
return await this.fetchFn()(this.endpointUrl(), {
|
|
408
|
+
method: "POST",
|
|
409
|
+
headers,
|
|
410
|
+
body: JSON.stringify(body),
|
|
411
|
+
signal: controller.signal,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
finally {
|
|
415
|
+
clearTimeout(timer);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async ensureSession() {
|
|
419
|
+
if (this.ready)
|
|
420
|
+
return;
|
|
421
|
+
if (this.sessionPromise === null) {
|
|
422
|
+
this.sessionPromise = (async () => {
|
|
423
|
+
const initId = this.nextId();
|
|
424
|
+
const initRes = await this.post({
|
|
425
|
+
jsonrpc: "2.0",
|
|
426
|
+
id: initId,
|
|
427
|
+
method: "initialize",
|
|
428
|
+
params: {
|
|
429
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
430
|
+
capabilities: {},
|
|
431
|
+
clientInfo: { name: "chelseaguide", version: VERSION },
|
|
432
|
+
},
|
|
433
|
+
}, false);
|
|
434
|
+
const sessionId = initRes.headers.get("mcp-session-id");
|
|
435
|
+
if (sessionId)
|
|
436
|
+
this.sessionId = sessionId;
|
|
437
|
+
const initText = await initRes.text();
|
|
438
|
+
const initParsed = parseRpcBody(initText, initId);
|
|
439
|
+
if (initParsed !== null && initParsed.error) {
|
|
440
|
+
throw new Error(rpcErrorMessage(initParsed.error));
|
|
441
|
+
}
|
|
442
|
+
if (initRes.status < 200 || initRes.status >= 300) {
|
|
443
|
+
throw new Error(`HTTP ${initRes.status}`);
|
|
444
|
+
}
|
|
445
|
+
if (initParsed === null && initText.trim() !== "") {
|
|
446
|
+
throw new Error("malformed response");
|
|
447
|
+
}
|
|
448
|
+
const initializedRes = await this.post({ jsonrpc: "2.0", method: "notifications/initialized" }, true);
|
|
449
|
+
try {
|
|
450
|
+
await initializedRes.text();
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
// Nothing needed from the notification response body.
|
|
454
|
+
}
|
|
455
|
+
this.ready = true;
|
|
456
|
+
})();
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
await this.sessionPromise;
|
|
460
|
+
}
|
|
461
|
+
catch (err) {
|
|
462
|
+
this.sessionPromise = null;
|
|
463
|
+
this.sessionId = null;
|
|
464
|
+
throw err;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** Forward one tool call; upstream failures come back as isError results. */
|
|
468
|
+
async callTool(name, args) {
|
|
469
|
+
try {
|
|
470
|
+
await this.ensureSession();
|
|
471
|
+
}
|
|
472
|
+
catch (err) {
|
|
473
|
+
return errorResult(err instanceof Error ? err.message : String(err));
|
|
474
|
+
}
|
|
475
|
+
const callId = this.nextId();
|
|
476
|
+
let callRes;
|
|
477
|
+
try {
|
|
478
|
+
callRes = await this.post({
|
|
479
|
+
jsonrpc: "2.0",
|
|
480
|
+
id: callId,
|
|
481
|
+
method: "tools/call",
|
|
482
|
+
params: { name, arguments: args ?? {} },
|
|
483
|
+
}, true);
|
|
484
|
+
}
|
|
485
|
+
catch (err) {
|
|
486
|
+
return errorResult(`request failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
487
|
+
}
|
|
488
|
+
const parsed = parseRpcBody(await callRes.text(), callId);
|
|
489
|
+
if (parsed !== null && parsed.error) {
|
|
490
|
+
return errorResult(rpcErrorMessage(parsed.error));
|
|
491
|
+
}
|
|
492
|
+
if (callRes.status < 200 || callRes.status >= 300) {
|
|
493
|
+
return errorResult(`HTTP ${callRes.status}`);
|
|
494
|
+
}
|
|
495
|
+
if (parsed === null)
|
|
496
|
+
return errorResult("malformed response");
|
|
497
|
+
const result = parsed.result;
|
|
498
|
+
if (result === undefined || result === null || typeof result !== "object") {
|
|
499
|
+
return errorResult("malformed response");
|
|
500
|
+
}
|
|
501
|
+
// Hand the upstream result back exactly as received.
|
|
502
|
+
return result;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/** Build a forwarding client; tests inject a fake fetch and env through deps. */
|
|
506
|
+
export function createClient(deps = {}) {
|
|
507
|
+
return new ChelseaguideClient(deps);
|
|
508
|
+
}
|
|
509
|
+
/** One-shot helper: a fresh client for a single call (the CLI path). */
|
|
510
|
+
export async function callTool(name, args, deps = {}) {
|
|
511
|
+
return new ChelseaguideClient(deps).callTool(name, args);
|
|
512
|
+
}
|
|
513
|
+
//# sourceMappingURL=forward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.js","sourceRoot":"","sources":["../src/forward.ts"],"names":[],"mappings":"AA2CA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;AAElE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAE7C,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AAExE,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC;QACE,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,qBAAqB;QAC9B,aAAa,EAAE,wOAAwO;QACvP,aAAa,EAAE;YACb,MAAM,EAAE,QAAQ;YAChB,sBAAsB,EAAE,KAAK;YAC7B,YAAY,EAAE;gBACZ,UAAU,EAAE;oBACV,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,QAAQ;wBACR,QAAQ;wBACR,YAAY;wBACZ,KAAK;wBACL,MAAM;wBACN,MAAM;wBACN,KAAK;wBACL,QAAQ;wBACR,QAAQ;wBACR,WAAW;wBACX,OAAO;qBACR;oBACD,aAAa,EAAE,kDAAkD;iBAClE;gBACD,KAAK,EAAE;oBACL,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,YAAY;wBACZ,WAAW;wBACX,WAAW;wBACX,iBAAiB;wBACjB,cAAc;wBACd,WAAW;wBACX,gBAAgB;wBAChB,YAAY;wBACZ,kBAAkB;wBAClB,QAAQ;wBACR,QAAQ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-0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chelseaguide MCP server. Tools: the 7 captured tools for
|
|
3
|
+
* the hosted service at knowchelsea.com (see forward.ts).
|
|
4
|
+
*
|
|
5
|
+
* This file uses the low-level Server API rather than
|
|
6
|
+
* McpServer: the high-level helper rebuilds schemas from
|
|
7
|
+
* zod and rewrites what is served, which would break
|
|
8
|
+
* exact parity with the captured tools/list. Here
|
|
9
|
+
* tools/list is answered locally from the core's literal
|
|
10
|
+
* definitions — the verbatim objects from the upstream
|
|
11
|
+
* capture — and every tools/call is forwarded upstream.
|
|
12
|
+
*
|
|
13
|
+
* A forwarded result returns unchanged, upstream isError
|
|
14
|
+
* flag and extra fields included. An upstream failure
|
|
15
|
+
* arrives as an isError result carrying an
|
|
16
|
+
* `chelseaguide error:` text, built by the forwarding
|
|
17
|
+
* client. Unknown tool names are rejected with McpError
|
|
18
|
+
* MethodNotFound, and non-object arguments with McpError
|
|
19
|
+
* InvalidParams, before any network hop is made.
|
|
20
|
+
*/
|
|
21
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
22
|
+
import { type ChelseaguideClient } from "./forward.js";
|
|
23
|
+
import type { ForwardDeps, ToolResult } from "./types.js";
|
|
24
|
+
/**
|
|
25
|
+
* Validate and forward a single tools/call through
|
|
26
|
+
* `client`. Exported so this layer can be tested directly
|
|
27
|
+
* without a stdio transport.
|
|
28
|
+
*/
|
|
29
|
+
export declare function handleCallTool(client: ChelseaguideClient, name: string, args: unknown): Promise<ToolResult>;
|
|
30
|
+
/** Build the stdio MCP server (transport not yet connected). */
|
|
31
|
+
export declare function createServer(deps?: ForwardDeps): Server;
|
|
32
|
+
/** Connect the MCP server over stdio. */
|
|
33
|
+
export declare function startMcpServer(deps?: ForwardDeps): Promise<void>;
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chelseaguide MCP server. Tools: the 7 captured tools for
|
|
3
|
+
* the hosted service at knowchelsea.com (see forward.ts).
|
|
4
|
+
*
|
|
5
|
+
* This file uses the low-level Server API rather than
|
|
6
|
+
* McpServer: the high-level helper rebuilds schemas from
|
|
7
|
+
* zod and rewrites what is served, which would break
|
|
8
|
+
* exact parity with the captured tools/list. Here
|
|
9
|
+
* tools/list is answered locally from the core's literal
|
|
10
|
+
* definitions — the verbatim objects from the upstream
|
|
11
|
+
* capture — and every tools/call is forwarded upstream.
|
|
12
|
+
*
|
|
13
|
+
* A forwarded result returns unchanged, upstream isError
|
|
14
|
+
* flag and extra fields included. An upstream failure
|
|
15
|
+
* arrives as an isError result carrying an
|
|
16
|
+
* `chelseaguide error:` text, built by the forwarding
|
|
17
|
+
* client. Unknown tool names are rejected with McpError
|
|
18
|
+
* MethodNotFound, and non-object arguments with McpError
|
|
19
|
+
* InvalidParams, before any network hop is made.
|
|
20
|
+
*/
|
|
21
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
22
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
23
|
+
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
24
|
+
import { createClient, isKnownTool, TOOL_DEFS, VERSION, } from "./forward.js";
|
|
25
|
+
/**
|
|
26
|
+
* Validate and forward a single tools/call through
|
|
27
|
+
* `client`. Exported so this layer can be tested directly
|
|
28
|
+
* without a stdio transport.
|
|
29
|
+
*/
|
|
30
|
+
export async function handleCallTool(client, name, args) {
|
|
31
|
+
if (!isKnownTool(name)) {
|
|
32
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
33
|
+
}
|
|
34
|
+
if (args !== undefined &&
|
|
35
|
+
(typeof args !== "object" || args === null || Array.isArray(args))) {
|
|
36
|
+
throw new McpError(ErrorCode.InvalidParams, `Arguments for tool ${name} must be a JSON object`);
|
|
37
|
+
}
|
|
38
|
+
return client.callTool(name, (args ?? {}));
|
|
39
|
+
}
|
|
40
|
+
/** Build the stdio MCP server (transport not yet connected). */
|
|
41
|
+
export function createServer(deps = {}) {
|
|
42
|
+
const client = createClient(deps);
|
|
43
|
+
const server = new Server({ name: "chelseaguide", version: VERSION }, { capabilities: { tools: {} } });
|
|
44
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
45
|
+
tools: TOOL_DEFS,
|
|
46
|
+
}));
|
|
47
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
48
|
+
const { name, arguments: args } = request.params;
|
|
49
|
+
const result = await handleCallTool(client, name, args);
|
|
50
|
+
return result;
|
|
51
|
+
});
|
|
52
|
+
return server;
|
|
53
|
+
}
|
|
54
|
+
/** Connect the MCP server over stdio. */
|
|
55
|
+
export async function startMcpServer(deps = {}) {
|
|
56
|
+
await createServer(deps).connect(new StdioServerTransport());
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,GAER,MAAM,cAAc,CAAC;AAGtB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA0B,EAC1B,IAAY,EACZ,IAAa;IAEb,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,iBAAiB,IAAI,EAAE,CA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AC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chelseaguide types.
|
|
3
|
+
*
|
|
4
|
+
* This package holds no data of its own. It is a forwarding
|
|
5
|
+
* client: the captured surface for the hosted service at knowchelsea.com
|
|
6
|
+
* is kept as plain data (ToolDef entries served verbatim for
|
|
7
|
+
* tools/list) and each tools/call is sent to that hosted MCP
|
|
8
|
+
* endpoint through an injectable fetch, so the whole test
|
|
9
|
+
* suite can run against a stubbed upstream with no live
|
|
10
|
+
* network.
|
|
11
|
+
*/
|
|
12
|
+
/** One captured tool definition, served exactly as captured for tools/list. */
|
|
13
|
+
export interface ToolDef {
|
|
14
|
+
name: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: Record<string, unknown>;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Arguments for a tool call, as decoded JSON. */
|
|
21
|
+
export type ToolArgs = Record<string, unknown>;
|
|
22
|
+
/** A tools/call result: upstream payloads pass through verbatim; local failures use this shape too. */
|
|
23
|
+
export interface ToolResult {
|
|
24
|
+
content?: unknown;
|
|
25
|
+
isError?: boolean;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** The narrow slice of a fetch Response the forwarding client relies on. */
|
|
29
|
+
export interface FetchResponseLike {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
status: number;
|
|
32
|
+
headers: {
|
|
33
|
+
get(name: string): string | null;
|
|
34
|
+
};
|
|
35
|
+
text(): Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
/** Injectable fetch function, so tests never reach the live network. */
|
|
38
|
+
export type FetchFn = (url: string, init?: {
|
|
39
|
+
method?: string;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
body?: string;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}) => Promise<FetchResponseLike>;
|
|
44
|
+
/** Injectable runtime dependencies for the forwarding client. */
|
|
45
|
+
export interface ForwardDeps {
|
|
46
|
+
/** Fetch implementation. Defaults to the global fetch. */
|
|
47
|
+
fetchFn?: FetchFn;
|
|
48
|
+
/** Environment (KNOWCHELSEA_MCP_URL). Defaults to process.env. */
|
|
49
|
+
env?: Record<string, string | undefined>;
|
|
50
|
+
/** Endpoint URL override. Defaults to env KNOWCHELSEA_MCP_URL or the pinned default. */
|
|
51
|
+
url?: string;
|
|
52
|
+
/** Per-request timeout in milliseconds. Defaults to 30000. */
|
|
53
|
+
timeoutMs?: number;
|
|
54
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chelseaguide types.
|
|
3
|
+
*
|
|
4
|
+
* This package holds no data of its own. It is a forwarding
|
|
5
|
+
* client: the captured surface for the hosted service at knowchelsea.com
|
|
6
|
+
* is kept as plain data (ToolDef entries served verbatim for
|
|
7
|
+
* tools/list) and each tools/call is sent to that hosted MCP
|
|
8
|
+
* endpoint through an injectable fetch, so the whole test
|
|
9
|
+
* suite can run against a stubbed upstream with no live
|
|
10
|
+
* network.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@reneturcios/chelseaguide",
|
|
3
|
-
"version": "0.0.0-stage",
|
|
4
|
-
"stub": true,
|
|
5
|
-
"description": "Temporary package placeholder for staged publishing"
|
|
6
|
-
}
|
|
1
|
+
{"bin":{"chelseaguide":"dist/cli.js"},"dependencies":{"@modelcontextprotocol/sdk":"^1","zod":"^4"},"description":"Curated Chelsea places and guides: list, search, compare and nearby lookup. Forwarded from the hosted upstream MCP service. One bin serves a small CLI and the MCP server.","devDependencies":{"@types/node":"^20","tsx":"^4","typescript":"^5"},"engines":{"node":">=20"},"files":["dist","server.json"],"homepage":"https://github.com/CloudCorpRecords/chelseaguide#readme","license":"MIT","mcpName":"io.github.CloudCorpRecords/chelseaguide","name":"@reneturcios/chelseaguide","private":false,"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/CloudCorpRecords/chelseaguide.git"},"scripts":{"build":"tsc","dev":"tsx src/cli.ts","test":"tsx --test test/*.test.ts"},"type":"module","version":"0.1.0"}
|
package/server.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$schema":"https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json","description":"Curated Chelsea places and guides: list, search, compare and nearby lookup.","name":"io.github.CloudCorpRecords/chelseaguide","packages":[{"identifier":"@reneturcios/chelseaguide","packageArguments":[{"type":"positional","value":"mcp"}],"registryBaseUrl":"https://registry.npmjs.org","registryType":"npm","runtimeHint":"npx","transport":{"type":"stdio"},"version":"0.1.0"},{"identifier":"ghcr.io/cloudcorprecords/chelseaguide:0.1.0","packageArguments":[{"type":"positional","value":"mcp"}],"registryType":"oci","runtimeArguments":[{"name":"--rm","type":"named"},{"name":"-i","type":"named"}],"runtimeHint":"docker","transport":{"type":"stdio"}}],"repository":{"source":"github","url":"https://github.com/CloudCorpRecords/chelseaguide"},"version":"0.1.0"}
|