npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

synaptra

v1.0.1

Published

A high-performance Model Context Protocol server for GraphQL APIs with advanced features, type-safety, and developer experience improvements

Readme

Synaptra 🚀

npm version License: MIT TypeScript

Synaptra is a high-performance Model Context Protocol (MCP) server for GraphQL APIs. It provides seamless integration between LLMs and GraphQL endpoints with advanced features like schema introspection, query optimization, caching, and comprehensive security controls.

✨ Features

  • 🔍 Automatic Schema Introspection - Discovers and exposes GraphQL schema structures
  • 🚀 High Performance - Built-in caching and query optimization
  • 🛡️ Enterprise Security - Rate limiting, query complexity analysis, and depth limiting
  • 🔧 Flexible Configuration - Environment variables, config files, and runtime options
  • 📊 Advanced Logging - Comprehensive query and performance logging
  • 🎯 Type Safety - Full TypeScript support with generated types
  • 🔄 Real-time Support - GraphQL subscriptions (configurable)
  • 🎛️ Developer Experience - Rich error handling and debugging tools

📦 Installation

npm install synaptra

🚀 Quick Start

As a Library

import { createMcpGraphQLServer } from 'synaptra';

// Create server
const server = createMcpGraphQLServer({
  name: 'my-graphql-api',
  endpoint: 'https://api.example.com/graphql',
  headers: {
    'Authorization': 'Bearer your-token-here'
  }
});

// Get client for operations
const client = server.getClient();

// Execute queries
const result = await client.executeQuery({
  query: `
    query GetUsers {
      users(limit: 10) {
        id
        name
        email
      }
    }
  `
});

CLI Usage

# Start MCP server
npx synaptra --endpoint https://api.example.com/graphql --name my-api

# With authentication
npx synaptra --endpoint https://api.example.com/graphql --api-key your-key --name my-api

📖 Configuration

Server Configuration

interface McpGraphQLConfig {
  name: string;                    // Server name
  endpoint: string;                // GraphQL endpoint URL
  defaultApiKey?: string;          // Optional default API key
  headers?: Record<string, string>; // Default headers
  allowMutations?: boolean;        // Allow mutations (default: true)
  allowSubscriptions?: boolean;    // Allow subscriptions (default: false)
  timeout?: number;                // Request timeout in ms (default: 30000)
  retries?: number;                // Retry attempts (default: 3)
  
  // Security settings
  security?: {
    maxDepth?: number;             // Max query depth (default: 15)
    maxComplexity?: number;        // Max query complexity (default: 1000)
    allowIntrospection?: boolean;  // Allow introspection (default: true)
  };
  
  // Logging configuration
  logging?: {
    level?: 'error' | 'warn' | 'info' | 'debug';
    queries?: boolean;             // Log queries (default: false)
    performance?: boolean;         // Log performance metrics
  };
}

Environment Variables

SYNAPTRA_ENDPOINT=https://api.example.com/graphql
SYNAPTRA_API_KEY=your-api-key
SYNAPTRA_TIMEOUT=30000
LOG_LEVEL=info

🔧 Advanced Usage

Per-Request Authentication

// Execute query with custom headers
const result = await client.executeQuery({
  query: 'query { users { id name } }',
  headers: {
    'Authorization': 'Bearer user-specific-token',
    'X-User-ID': '12345'
  }
});

Schema Analysis

// Introspect schema
const schema = await client.introspectSchema();
console.log('Schema types:', schema.types.length);

// Analyze query complexity
const analysis = await client.analyzeQuery(`
  query ComplexQuery {
    users {
      posts {
        comments {
          author { name }
        }
      }
    }
  }
`);
console.log('Complexity:', analysis.complexity);
console.log('Depth:', analysis.depth);

Dynamic Configuration

// Update configuration at runtime
server.updateConfig({
  timeout: 60000,
  security: { maxDepth: 10 },
  logging: { level: 'debug' }
});

🛡️ Security Features

Query Analysis

  • Depth Limiting: Prevent deeply nested queries that could cause performance issues
  • Complexity Analysis: Calculate and limit query complexity scores
  • Timeout Protection: Automatic request timeout and cancellation

Authentication

  • Flexible Auth: Support for API keys, bearer tokens, custom headers
  • Per-Request Keys: Override authentication on each request
  • Secure Headers: Automatic header sanitization and validation

📊 Monitoring & Debugging

Built-in Logging

const server = createMcpGraphQLServer({
  endpoint: 'https://api.example.com/graphql',
  logging: {
    level: 'debug',
    queries: true,        // Log all queries
    performance: true     // Log execution times
  }
});

Performance Metrics

// Get performance statistics
const stats = client.getPerformanceStats();
console.log('Average response time:', stats.averageResponseTime);
console.log('Total requests:', stats.totalRequests);
console.log('Error rate:', stats.errorRate);

🧪 Testing

# Run all tests
npm test

# Run integration tests
npm run test:integration

# Test with your GraphQL endpoint
npm run test:local

📋 API Reference

Methods

createMcpGraphQLServer(config: McpGraphQLConfig)

Creates a new MCP GraphQL server instance.

server.getClient()

Returns the GraphQL client for executing operations.

client.executeQuery(options: QueryOptions)

Executes a GraphQL query with optional custom headers.

client.introspectSchema()

Performs schema introspection and returns schema information.

client.analyzeQuery(query: string)

Analyzes query complexity and depth.

server.updateConfig(config: Partial<McpGraphQLConfig>)

Updates server configuration at runtime.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your 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 MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Made with ❤️ for the MCP and GraphQL communities