https://github.com/niallroche/raphtory_mcp
https://github.com/niallroche/raphtory_mcp
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/niallroche/raphtory_mcp
- Owner: niallroche
- License: apache-2.0
- Created: 2025-03-20T13:08:56.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-20T17:27:53.000Z (7 months ago)
- Last Synced: 2025-03-20T18:32:33.034Z (7 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Raphtory GraphQL Schema Explorer
This Python module provides a FastMCP server that exposes GraphQL schema information for Raphtory graphs through a set of HTTP resources. It allows LLMs to explore and understand the structure of graphs, including node properties and relationship types.
## Features
### 1. Graph Schema Querying
- Query the schema of specific graphs by name
- Retrieve detailed property information for nodes
- Get unique relationship types and their metadata
- Optional inclusion of property variants### 2. Resources
#### `schema://database`
Returns the complete GraphQL schema for the database, including:
- All available types
- Fields for each type
- Field descriptions
- Arguments and their default values#### `schema://graph_exists/{graph_name}`
Verifies if a specific graph exists in the database by checking for the presence of nodes.#### `schema://{graph_name}/{include_variants}`
Returns detailed schema information for a specific graph:
- Node Properties:
- Property keys
- Property types (e.g., "Str")
- Optional property variants
- Relationships:
- Unique relationship types (e.g., "edge_type_1", "edge_type_2", "edge_type_3")### 3. Implementation Details
The module uses:
- An executing Raphtory GraphQL server (this needs to be running)
- `httpx` for async HTTP requests with HTTP/2 support
- FastMCP for resource management
- Persistent connections through a global async client
- Context management for proper resource cleanup## Example Usage
Query a graph schema:
```graphql
{
graph(path: "your_graph_name") {
schema {
nodes {
properties {
key
propertyType
}
}
}
edges {
list {
properties {
keys
values {
value
}
}
}
}
}
}
```## Response Format
The schema response includes values like:
```json
{
"data": {
"graph": {
"schema": {
"nodes": [{
"properties": [
{"key": "name", "propertyType": "Str"},
{"key": "type", "propertyType": "Str"}
// ... other properties
]
}]
},
"relationships": [
"edge_type_1",
"edge_type_2",
"edge_type_3"
]
}
}
}
```## Error Handling
The module includes error handling for:
- Non-existent graphs
- Invalid queries
- Connection issues
- Malformed responses## Dependencies
- FastMCP
- httpx
- Python 3.x
- a running Raphtory GraphQL endpoint (default: http://localhost:1736/)## Configuration
The module uses default configuration:
- HTTP/2 enabled
- 10-second timeout
- Content-Type: application/jsonAdditional configuration (like authentication) can be added through environment variables.