Skip to content

Commit ac854d7

Browse files
committed
Merge branch '3.8-dev'
2 parents 3770aef + 3d94ba7 commit ac854d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+16061
-28
lines changed

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ env:
44
# modules commonly excluded from builds as they have their own independent non-JVM setups and can be run in parallel.
55
# take care when modifying this list because GLVs use shell commands to remove themselves from this list and
66
# modifications could break patterns of replacement they are searching for.
7-
EXCLUDE_MODULES: '-:gremlin-dotnet-source,-:gremlin-dotnet-tests,-:gremlin-go,-:gremlin-javascript,-:gremlint,-:gremlin-python'
7+
EXCLUDE_MODULES: '-:gremlin-dotnet-source,-:gremlin-dotnet-tests,-:gremlin-go,-:gremlin-javascript,-:gremlint,-:gremlin-mcp,-:gremlin-python'
88
EXCLUDE_FOR_GLV: '-:gremlin-annotations,-:gremlin-console,-:hadoop-gremlin,-:neo4j-gremlin,-:spark-gremlin,-:sparql-gremlin'
99
jobs:
1010
smoke:
@@ -237,7 +237,7 @@ jobs:
237237
# run: |
238238
# EXCLUDE="-:gremlin-dotnet-source,-:gremlin-dotnet-tests,-:gremlin-go,-:gremlin-python,$EXCLUDE_FOR_GLV"
239239
# mvn clean install -pl $EXCLUDE -q -DskipTests -Dci
240-
# mvn verify -pl :gremlin-javascript,:gremlint
240+
# mvn verify -pl :gremlin-javascript,:gremlint,:gremlin-mcp
241241
python:
242242
name: python
243243
timeout-minutes: 20

CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
9191
9292
This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
9393
94+
* Added a Gremln MCP server.
9495
* Added the Air Routes dataset to the set of available samples packaged with distributions.
9596
* Added a minimal distribution for `tinkergraph-gremlin` using the `min` classifier that doesn't include the sample datasets.
9697
* Removed Vertex/ReferenceVertex from grammar. Use vertex id in traversals now instead.

docs/src/dev/developer/development-environment.asciidoc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,25 @@ See the <<release-environment,Release Environment>> section for more information
309309
[[nodejs-environment]]
310310
=== JavaScript Environment
311311
312-
When building `gremlin-javascript`, mvn command will include a local copy of Node.js runtime and npm inside your project
313-
using `com.github.eirslett:frontend-maven-plugin` plugin. This copy of the Node.js runtime will not affect any
314-
other existing Node.js runtime instances in your machine.
312+
When building `gremlin-javascript`, `gremlint` and `gremlin-mcp`, the `mvn` command will include a local copy of Node.js
313+
runtime and npm inside your project using `com.github.eirslett:frontend-maven-plugin` plugin. This copy of the Node.js
314+
runtime will not affect any other existing Node.js runtime instances in your machine.
315315
316-
To run the development and build scripts of `gremlint` and its corresponding web page `docs/gremlint`, Node.js and npm
317-
have to be installed. When generating or publishing the TinkerPop website, the `docs/gremlint` web page has to be
316+
To run the development and build scripts of the web app in `docs/gremlint`, Node.js and npm have to be installed on the
317+
local system at this time. When generating or publishing the TinkerPop website, the `docs/gremlint` web page has to be
318318
built. Consequently, the scripts `bin/generate-home.sh` and `bin/publish-home.sh` require that Node.js and npm are
319-
installed. Version 8.x or newer of npm is required. This is covered in more detail in the <<site,Site>> section.
319+
installed. Check the root `pom.xml` for the `runtime.node.version` property for the minimum version required. This is
320+
covered in more detail in the <<site,Site>> section.
320321
321-
As of TinkerPop 3.5.5, `gremlin-javascript` uses Docker for all tests inside of Maven. Please make sure Docker is
322-
installed and running on your system.
322+
A fast way to test `grelin-mcp` after doing a build is to use link:https://modelcontextprotocol.io/docs/tools/inspector[@modelcontextprotocol/inspector]
323+
which will start up the Gremlin MCP server and present a browser-based tool to use the commands. It is most easily
324+
launched with `npx` as follows:
325+
326+
[source,text]
327+
----
328+
# from the root of the repository
329+
$ npx @modelcontextprotocol/inspector node gremlin-mcp/src/main/javascript/dist/server.js -e GREMLIN_MCP_ENDPOINT=localhost:8182/g -e GREMLIN_MCP_LOG_LEVEL=info
330+
----
323331
324332
IMPORTANT: Beware of unexpected or unwanted changes on `package-lock.json` files when committing and merging.
325333

docs/src/reference/gremlin-applications.asciidoc

Lines changed: 119 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ scrubbing, it would be quite simple to do:
18821882
18831883
[source,java]
18841884
----
1885-
String lbl = "person"
1885+
String lbl = "person";
18861886
String nodeId = "mary').next();g.V().drop().iterate();g.V().has('id', 'thomas";
18871887
String query = "g.addV('" + lbl + "').property('identifier','" + nodeId + "')";
18881888
client.submit(query);
@@ -1894,13 +1894,13 @@ part of the "identifier" for the vertex on insertion:
18941894
18951895
[source,java]
18961896
----
1897-
String lbl = "person"
1897+
String lbl = "person";
18981898
String nodeId = "mary').next();g.V().drop().iterate();g.V().has('id', 'thomas";
18991899
String query = "g.addV(lbl).property('identifier',nodeId)";
19001900
19011901
Map<String,Object> params = new HashMap<>();
1902-
params.put("lbl",lbl);
1903-
params.put("nodeId",nodeId);
1902+
params.put("lbl", lbl);
1903+
params.put("nodeId", nodeId);
19041904
client.submit(query, params);
19051905
----
19061906
@@ -2336,3 +2336,118 @@ for `HadoopGraph`:
23362336
----
23372337
describeGraph(HadoopGraph)
23382338
----
2339+
2340+
[[gremlin-mcp]]
2341+
=== Gremlin MCP
2342+
2343+
Gremlin MCP integrates Apache TinkerPop with the Model Context Protocol (MCP) so that MCP‑capable assistants (for
2344+
example, desktop chat clients that support MCP) can discover your graph, run Gremlin traversals and exchange graph data
2345+
through a small set of well‑defined tools. It allows users to “talk to your graph” while keeping full Gremlin power
2346+
available when they or the assistant need it.
2347+
2348+
MCP is an open protocol that lets assistants call server‑hosted tools in a structured way. Each tool has a name, an
2349+
input schema, and a result schema. When connected to a Gremlin MCP server, the assistant can:
2350+
2351+
* Inspect the server’s health and connection to a Gremlin data source
2352+
* Discover the graph’s schema (labels, properties, relationships, counts)
2353+
* Execute Gremlin traversals
2354+
2355+
The Gremlin MCP server sits alongside Gremlin Server (or any TinkerPop‑compatible endpoint) and forwards tool calls to
2356+
the graph via standard Gremlin traversals.
2357+
2358+
IMPORTANT: This MCP server is designed for development and trusted environments.
2359+
2360+
WARNING: Gremlin MCP can modify the graph to which it is connected. To prevent such changes, ensure that Gremlin MCP is
2361+
configured to work against a read-only instance of the graph. Gremlin Server hosted graphs can configure their graph
2362+
using `withStrategies(ReadOnlyStrategy)` for that protection.
2363+
2364+
WARNING: Gremlin MCP executes global graph traversals to help it understand the schema and gather statistics. On a large
2365+
graph these queries will be costly. If you are trying Gremlin MCP, please try it with a smaller subset of your graph for
2366+
experimentation purposes.
2367+
2368+
MCP defines a simple request/response model for invoking named tools. A tool declares its input and output schema so an
2369+
assistant can construct valid calls and reason about results. The Gremlin MCP server implements several tools and, when
2370+
invoked by an MCP client, translates those calls to Gremlin traversals against a configured Gremlin endpoint. The
2371+
endpoint is typically Gremlin Server, but could be used with any graph system that implements its protocols.
2372+
2373+
TIP: Gremlin MCP does not replace Gremlin itself. It complements it by helping assistants discover data and propose
2374+
traversals. You can always provide an explicit traversal when you know what you want.
2375+
2376+
The Gremlin MCP server exposes these tools:
2377+
2378+
* `get_graph_status` — Returns basic health and connectivity information for the backing Gremlin data source.
2379+
* `get_graph_schema` — Discovers vertex labels, edge labels, property keys, and relationship patterns. Low‑cardinality
2380+
properties may be surfaced as enums to encourage valid values in queries.
2381+
* `run_gremlin_query` — Executes an arbitrary Gremlin traversal and returns JSON results.
2382+
* `refresh_schema_cache` — Forces schema discovery to run again when the graph has changed.
2383+
2384+
==== Schema discovery
2385+
2386+
Schema discovery is the foundation that lets humans and AI assistants reason about a graph without prior tribal
2387+
knowledge. By automatically mapping the graph’s structure and commonly observed patterns, it produces a concise,
2388+
trustworthy description that accelerates onboarding, improves the quality of suggested traversals, and reduces
2389+
trial‑and‑error against production data. For assistants, a discovered schema becomes the guidance layer for planning
2390+
valid queries, generating meaningful filters, and explaining results in natural language. For operators, it offers safer
2391+
and more efficient interactions by avoiding blind exploratory scans, enabling caching and change detection, and
2392+
providing hooks to steer what should or shouldn’t be surfaced (for example, excluding sensitive or non‑categorical
2393+
fields). In short, schema discovery turns an opaque dataset into an actionable contract between your graph and the tools
2394+
that use it.
2395+
2396+
Schema discovery uses Gremlin traversals and sampling to uncover the following information about the graph:
2397+
2398+
* Labels - Vertex and edge labels are collected and de‑duplicated.
2399+
* Properties - For each label, a sample of elements is inspected to list observed property keys.
2400+
* Counts (optional) - Approximate counts can be included per label.
2401+
* Relationship patterns - Connectivity is derived from the labels of edges and their incident vertices.
2402+
* Enums - Properties with a small set of distinct values may be surfaced as enumerations to promote precise filters.
2403+
2404+
==== Executing traversals
2405+
2406+
When the assistant needs to answer a question, a common sequence is:
2407+
2408+
. Optionally, call get_graph_status.
2409+
. Retrieve (or reuse) schema via `get_graph_schema`.
2410+
. Formulate a traversal and call `run_gremlin_query`.
2411+
. Present results and, if required, refine the traversal.
2412+
2413+
For example, the assistant may execute a traversal like the following:
2414+
2415+
[source,groovy]
2416+
----
2417+
// list the names of people over 30 and who they know
2418+
g.V().hasLabel('person').has('age', gt(30)).out('knows').values('name')
2419+
----
2420+
2421+
==== Configuring an MCP Client
2422+
2423+
The MCP client is responsible for launching the Gremlin MCP server and providing connection details for the Gremlin
2424+
endpoint the server should use.
2425+
2426+
Basic connection settings:
2427+
2428+
* `GREMLIN_MCP_ENDPOINT` — `host:port` or `host:port/traversal_source` for the target Gremlin Server or compatible endpoint (default traversal source: `g`)
2429+
* `GREMLIN_MCP_USE_SSL` — set to `true` when TLS is required by the endpoint (default: `false`)
2430+
* `GREMLIN_MCP_USERNAME` / `GREMLIN_PASSWORD` — credentials when authentication is enabled (optional)
2431+
* `GREMLIN_MCP_IDLE_TIMEOUT` — idle connection timeout in seconds (default: `300`)
2432+
* `GREMLIN_MCP_LOG_LEVEL` — logging verbosity for troubleshooting: `error`, `warn`, `info`, or `debug` (default: `info`)
2433+
2434+
Advanced schema discovery and performance tuning:
2435+
2436+
* `GREMLIN_MCP_ENUM_DISCOVERY_ENABLED` — enable enum property discovery (default: `true`)
2437+
* `GREMLIN_MCP_ENUM_CARDINALITY_THRESHOLD` — max distinct values for a property to be considered an enum (default: `10`)
2438+
* `GREMLIN_MCP_ENUM_PROPERTY_DENYLIST` — comma-separated property names to exclude from enum detection (default: `id,pk,name,description,startDate,endDate,timestamp,createdAt,updatedAt`)
2439+
* `GREMLIN_MCP_SCHEMA_MAX_ENUM_VALUES` — limit the number of enum values returned per property in the schema (default: `10`)
2440+
* `GREMLIN_MCP_SCHEMA_INCLUDE_SAMPLE_VALUES` — include small example values for properties in the schema (default: `false`)
2441+
* `GREMLIN_MCP_SCHEMA_INCLUDE_COUNTS` — include approximate vertex/edge label counts in the schema (default: `false`)
2442+
2443+
The configurations related to enums begs additional explanation as to their importance. Treating only truly categorical
2444+
properties as enums prevents misleading suggestions and sensitive data exposure in assistant‑facing schemas. Without a
2445+
denylist and related controls, low‑sample snapshots can make non‑categorical fields like IDs, timestamps, or free text
2446+
appear “enum‑like,” degrading query guidance and result explanations. By explicitly excluding such keys, the schema
2447+
remains focused on meaningful categories (e.g., status or type), which improves AI query formulation, reduces noise, and
2448+
avoids surfacing unstable or private values. It also streamlines schema discovery by skipping properties that would
2449+
create large or frequently changing value sets, improving performance and stability.
2450+
2451+
Consult the MCP client documentation for how environment variables are supplied and how tool calls are approved and
2452+
presented to the user.
2453+

docs/src/upgrade/release-3.8.x.asciidoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ complete list of all the modifications that are part of this release.
3030
3131
=== Upgrading for Users
3232
33+
==== Gremlin MCP Server
34+
35+
Gremlin MCP Server is an experimental application that implements the link:https://modelcontextprotocol.io/[Model Context Protocol]
36+
(MCP) to expose Gremlin Server-backed graph operations to MCP-capable clients such as Claude Desktop, Cursor, or
37+
Windsurf. Through this integration, graph structure can be discovered, and Gremlin traversals can be executed. Basic
38+
health checks are included to validate connectivity.
39+
40+
A running Gremlin Server that fronts the target TinkerPop graph is required. An MCP client can be configured to connect
41+
to the Gremlin MCP Server endpoint.
42+
3343
==== Air Routes Dataset
3444
3545
The Air Routes sample dataset has long been used to help showcase and teach Gremlin. Popularized by the first edition

gremlin-javascript/pom.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ limitations under the License.
2828
<properties>
2929
<maven.test.skip>false</maven.test.skip>
3030
<skipTests>${maven.test.skip}</skipTests>
31-
<npm.version>10.8.2</npm.version>
32-
<node.version>v20.19.4</node.version>
3331
</properties>
3432
<build>
3533
<directory>${basedir}/target</directory>
@@ -184,8 +182,8 @@ limitations under the License.
184182
</executions>
185183
<configuration>
186184
<workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
187-
<nodeVersion>${node.version}</nodeVersion>
188-
<npmVersion>${npm.version}</npmVersion>
185+
<nodeVersion>${runtime.node.version}</nodeVersion>
186+
<npmVersion>${runtime.npm.version}</npmVersion>
189187
</configuration>
190188
</plugin>
191189
<!--
@@ -354,8 +352,8 @@ limitations under the License.
354352
-->
355353
<skip>false</skip>
356354
<workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
357-
<nodeVersion>${node.version}</nodeVersion>
358-
<npmVersion>${npm.version}</npmVersion>
355+
<nodeVersion>${runtime.node.version}</nodeVersion>
356+
<npmVersion>${runtime.npm.version}</npmVersion>
359357
</configuration>
360358
</plugin>
361359
</plugins>

gremlin-javascript/src/main/javascript/gremlin-javascript/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"name": "gremlin",
33
"version": "4.0.0-alpha1",
44
"description": "JavaScript Gremlin Language Variant",
5-
"author": "Apache TinkerPop team",
5+
"author": {
6+
"name": "Apache TinkerPop team"
7+
},
68
"keywords": [
79
"graph",
810
"gremlin",
911
"tinkerpop",
12+
"apache-tinkerpop",
1013
"connection",
1114
"glv",
1215
"driver",
16+
"database",
1317
"graphdb"
1418
],
1519
"license": "Apache-2.0",

0 commit comments

Comments
 (0)