@yinyoudexing/geoc-collect-node-api-mcp 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/dist/server.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { realpathSync } from 'node:fs';
5
+ import { resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { z } from 'zod';
8
+ import { createApiClient } from './client.js';
9
+ import { zodFromJsonSchema } from './schema.js';
10
+ import { listGeocCollectTools } from './tools.js';
11
+ const DEFAULT_BASE_URL = 'http://localhost:6001';
12
+ export function createGeocCollectMcpServer() {
13
+ const apiClient = createApiClient({
14
+ baseUrl: process.env.GEOC_COLLECT_API_BASE_URL || DEFAULT_BASE_URL,
15
+ token: process.env.GEOC_COLLECT_API_TOKEN || process.env.GEOC_COLLECT_API_AUTHORIZATION,
16
+ ak: process.env.GEOC_COLLECT_API_AK,
17
+ });
18
+ const server = new McpServer({
19
+ name: 'geoc-collect-node-api',
20
+ version: '0.1.0',
21
+ });
22
+ for (const tool of listGeocCollectTools()) {
23
+ const inputSchema = tool.zodShape
24
+ ? z.object(tool.zodShape)
25
+ : zodFromJsonSchema(tool.inputSchema);
26
+ server.registerTool(tool.name, {
27
+ title: tool.title,
28
+ description: tool.description,
29
+ inputSchema,
30
+ annotations: tool.annotations ?? {
31
+ readOnlyHint: true,
32
+ },
33
+ }, async (args) => {
34
+ try {
35
+ const result = await apiClient.callTool(tool, args);
36
+ return {
37
+ content: [
38
+ {
39
+ type: 'text',
40
+ text: JSON.stringify(result, null, 2),
41
+ },
42
+ ],
43
+ };
44
+ }
45
+ catch (error) {
46
+ const message = error instanceof Error ? error.message : String(error);
47
+ return {
48
+ isError: true,
49
+ content: [
50
+ {
51
+ type: 'text',
52
+ text: message,
53
+ },
54
+ ],
55
+ };
56
+ }
57
+ });
58
+ }
59
+ return server;
60
+ }
61
+ export async function runStdioServer() {
62
+ const server = createGeocCollectMcpServer();
63
+ await server.connect(new StdioServerTransport());
64
+ }
65
+ export function isDirectRun(moduleUrl, argvPath) {
66
+ if (!argvPath)
67
+ return false;
68
+ return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(resolve(argvPath));
69
+ }
70
+ if (isDirectRun(import.meta.url, process.argv[1])) {
71
+ runStdioServer().catch((error) => {
72
+ console.error(error instanceof Error ? error.stack || error.message : String(error));
73
+ process.exit(1);
74
+ });
75
+ }
76
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD,MAAM,UAAU,0BAA0B;IACxC,MAAM,SAAS,GAAG,eAAe,CAAC;QAChC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,gBAAgB;QAClE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,8BAA8B;QACvF,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB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IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,MAAM,GAAG,0BAA0B,EAAE,CAAC;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,QAA4B;IACzE,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GeocCollectTool } from './types.js';
2
+ export declare function listGeocCollectTools(): readonly GeocCollectTool[];
3
+ export declare function getToolByName(name: string): GeocCollectTool;
package/dist/tools.js ADDED
@@ -0,0 +1,12 @@
1
+ import { OPENAPI_GEOC_COLLECT_TOOLS } from './generated-openapi-tools.js';
2
+ export function listGeocCollectTools() {
3
+ return OPENAPI_GEOC_COLLECT_TOOLS;
4
+ }
5
+ export function getToolByName(name) {
6
+ const tool = OPENAPI_GEOC_COLLECT_TOOLS.find((item) => item.name === name);
7
+ if (!tool) {
8
+ throw new Error(`Unknown geoc-collect-node MCP tool: ${name}`);
9
+ }
10
+ return tool;
11
+ }
12
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAG1E,MAAM,UAAU,oBAAoB;IAClC,OAAO,0BAA0B,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,IAAI,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC3E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { z } from 'zod';
2
+ import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
3
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4
+ export type JsonSchema = {
5
+ type?: string;
6
+ format?: string;
7
+ description?: string;
8
+ required?: readonly string[];
9
+ properties?: Readonly<Record<string, JsonSchema>>;
10
+ items?: JsonSchema;
11
+ additionalProperties?: boolean | JsonSchema;
12
+ enum?: readonly (string | number | boolean)[];
13
+ default?: unknown;
14
+ minimum?: number;
15
+ maximum?: number;
16
+ minLength?: number;
17
+ maxLength?: number;
18
+ example?: unknown;
19
+ examples?: readonly unknown[];
20
+ nullable?: boolean;
21
+ $ref?: string;
22
+ oneOf?: readonly JsonSchema[];
23
+ anyOf?: readonly JsonSchema[];
24
+ allOf?: readonly JsonSchema[];
25
+ };
26
+ export type GeocCollectTool = {
27
+ name: string;
28
+ title: string;
29
+ description: string;
30
+ method: HttpMethod;
31
+ path: string;
32
+ inputSchema: JsonSchema;
33
+ zodShape?: z.ZodRawShape;
34
+ pathParams?: readonly string[];
35
+ queryParams?: readonly string[];
36
+ headerParams?: readonly string[];
37
+ bodyParams?: readonly string[];
38
+ bodyContentType?: string;
39
+ hasRequestBody?: boolean;
40
+ annotations?: ToolAnnotations;
41
+ };
42
+ export type ApiClientOptions = {
43
+ baseUrl: string;
44
+ token?: string;
45
+ ak?: string;
46
+ fetch?: typeof fetch;
47
+ };
48
+ export type ToolArguments = Record<string, unknown>;
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@yinyoudexing/geoc-collect-node-api-mcp",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "MCP server for geoc-collect-node API tools",
6
+ "license": "UNLICENSED",
7
+ "type": "module",
8
+ "main": "./dist/server.js",
9
+ "types": "./dist/index.d.ts",
10
+ "bin": {
11
+ "geoc-collect-node-api-mcp": "dist/server.js"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "AGENT_SETUP.md",
16
+ "README.md",
17
+ "package.json"
18
+ ],
19
+ "engines": {
20
+ "node": ">=18.18.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.json",
27
+ "generate:tools": "node scripts/generate-openapi-tools.js",
28
+ "test": "vitest run",
29
+ "start": "node dist/server.js",
30
+ "prepack": "npm run build",
31
+ "prepublishOnly": "npm test"
32
+ },
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.20.0",
35
+ "zod": "^3.25.76"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.10.7",
39
+ "typescript": "^5.7.3",
40
+ "vitest": "^2.1.8"
41
+ }
42
+ }
43
+