[
https://issues.apache.org/jira/browse/TINKERPOP-3303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18143063#comment-18143063
]
ASF GitHub Bot commented on TINKERPOP-3303:
-------------------------------------------
spmallette commented on code in PR #3768:
URL: https://github.com/apache/tinkerpop/pull/3768#discussion_r4540444838
##########
gremlin-js/gremlin-mcp/src/docs/tools.ts:
##########
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview MCP tools serving TinkerPop reference and Gremlin Semantics
docs.
+ *
+ * Both tools take a required `version` whose allowed values are the docs
versions found at
+ * startup, published as an enum in the tool schema so the agent can see what
is available.
+ * There is no default: the agent must pass the version of its target server,
asking the user
+ * when it does not know, because docs for the wrong version are the failure
these tools exist
+ * to prevent.
+ */
+
+import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
+import { z } from 'zod';
+import { TOOL_NAMES } from '../constants.js';
+import {
+ createErrorResponse,
+ createStringResponse,
+ createSuccessResponse,
+} from '../handlers/tool-patterns.js';
+import { DocsSearchIndex } from './search.js';
+import { DOCS_SITE_URL, type DocPage, type DocsStore, type DocsVersion } from
'./store.js';
+import { stripFragment } from './selection.js';
+
+const DEFAULT_LIMIT = 10;
+const MAX_LIMIT = 25;
+
+/**
+ * Resolves what an agent passed as a page to a page id. Accepts a page id, a
link copied
+ * from a page (with or without a fragment), a site URL for the version, or a
bare file name
+ * when only one page has it.
+ */
+export const resolvePageId = (docs: DocsVersion, input: string): string |
undefined => {
+ let candidate = stripFragment(input.trim());
+ const siteBase = `${DOCS_SITE_URL}/${docs.version}/`;
+ if (candidate.startsWith(siteBase)) candidate =
candidate.slice(siteBase.length);
Review Comment:
https://issues.apache.org/jira/browse/TINKERPOP-3310
> Serve docs from gremlin-mcp
> ---------------------------
>
> Key: TINKERPOP-3303
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3303
> Project: TinkerPop
> Issue Type: Improvement
> Components: mcp
> Affects Versions: 3.8.2
> Reporter: Stephen Mallette
> Assignee: Stephen Mallette
> Priority: Major
>
> Serve markdown forms of TinkerPop documentation from gremlin-mcp
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)