Labsco
Arize-ai logo

Text-To-GraphQL

โ˜… 24

from Arize-ai

MCP server for text-to-graphql, integrates with Claude Desktop and Cursor.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

Text-to-GraphQL MCP Server

Transform natural language queries into GraphQL queries using an MCP (Model Context Protocol) server that integrates seamlessly with AI assistants like Claude Desktop and Cursor.

Install MCP Server

Claude Demo

๐Ÿš€ Overview

The Text-to-GraphQL MCP Server converts natural language descriptions into valid GraphQL queries using an AI agent built with LangGraph. It provides a bridge between human language and GraphQL APIs, making database and API interactions more intuitive for developers and non-technical users alike.

โœจ Features

  • Natural Language to GraphQL: Convert plain English queries to valid GraphQL
  • Schema Management: Load and introspect GraphQL schemas automatically
  • Query Validation: Validate generated queries against loaded schemas
  • Query Execution: Execute queries against GraphQL endpoints with authentication
  • Query History: Track and manage query history across sessions
  • MCP Protocol: Full compatibility with Claude Desktop, Cursor, and other MCP clients
  • Error Handling: Graceful error handling with detailed debugging information
  • Caching: Built-in caching for schemas and frequently used queries

๐Ÿ— Architecture

The system uses a multi-agent architecture built with LangGraph:

  1. Intent Recognition: Understands what the user wants to accomplish
  2. Schema Management: Loads and manages GraphQL schema information
  3. Query Construction: Builds GraphQL queries from natural language
  4. Query Validation: Ensures queries are valid against the schema
  5. Query Execution: Executes queries against the GraphQL endpoint
  6. Data Visualization: Provides recommendations for visualizing results

๐Ÿ” Observability & Agent Development

Want to build better AI agents quickly? Check out Arize Phoenix - an open-source observability platform specifically designed for LLM applications and agents. Phoenix provides:

  • Real-time monitoring of your agent's performance and behavior
  • Trace visualization to understand complex agent workflows
  • Evaluation frameworks for testing and improving agent responses
  • Data quality insights to identify issues with your training data
  • Cost tracking for LLM API usage optimization

Phoenix integrates seamlessly with LangChain and LangGraph (which this project uses) and can help you:

  • Debug agent behavior when queries aren't generated correctly
  • Monitor GraphQL query quality and success rates
  • Track user satisfaction and query complexity
  • Optimize your agent's prompt engineering

Get started with Phoenix:

pip install arize-phoenix
phoenix serve

Visit docs.arize.com/phoenix for comprehensive guides on agent observability and development best practices.

๐Ÿงช Development

Setup Development Environment

# Install development dependencies
uv pip install -e ".[dev]"

# Run tests
pytest

# Format code
black .
isort .

# Type checking
mypy src/

Project Structure

text-to-graphql-mcp/
โ”œโ”€โ”€ src/text_to_graphql_mcp/     # Main package
โ”‚   โ”œโ”€โ”€ mcp_server.py            # MCP server implementation
โ”‚   โ”œโ”€โ”€ agent.py                 # LangGraph agent logic
โ”‚   โ”œโ”€โ”€ config.py                # Configuration management
โ”‚   โ”œโ”€โ”€ logger.py                # Logging utilities
โ”‚   โ”œโ”€โ”€ tools/                   # Agent tools
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ tests/                       # Test suite
โ”œโ”€โ”€ docs/                        # Documentation
โ”œโ”€โ”€ pyproject.toml              # Package configuration
โ””โ”€โ”€ README.md

๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the Elastic License 2.0 (ELv2) - see the LICENSE file for details.

๐Ÿ™ Acknowledgments