Skip to main content

Context and Memory MCP

Project description

Daxia OpenAPI Client based MCP

Python Version FastMCP License uv

A FastMCP server that dynamically creates MCP tools from OpenAPI specifications, enabling seamless integration with any OpenAPI-compliant API.

Table of Contents

Features

  • 🚀 Dynamic Tool Generation: Automatically creates MCP tools from OpenAPI specifications
  • 🔐 OAuth2 Authentication: Automatic token retrieval from Daxia platform
  • 🌐 Flexible Configuration: Environment-based configuration for easy deployment
  • 📝 OpenAPI 3.x Support: Works with any valid OpenAPI 3.x specification
  • FastMCP Powered: Built on the high-performance FastMCP framework

Dependencies

This project requires Python 3.12 or higher and uses the following dependencies:

  • fastmcp (>=2.14.0) - FastMCP framework for building MCP servers
  • httpx (>=0.28.1) - Modern HTTP client for making API requests
  • requests (>=2.32.5) - HTTP library for additional compatibility

All dependencies are managed using uv for fast and reliable package management.

Installation

This project uses uv for dependency management.

Prerequisites

  1. Python 3.12 or higher

    python --version  # Should be 3.12 or higher
    
  2. Install uv

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

Installation Steps

  1. Clone the repository

    git clone <repository-url>
    cd daxiamcp
    
  2. Install the project

    uv pip install -e .
    

    This will:

    • Install all required dependencies
    • Create the daxiamcp command-line tool
    • Make the project available for development
  3. Verify the installation

    daxiamcp --help
    

Alternative: Using uvx

You can run the tool directly without installation using uvx:

uvx daxiamcp

This is particularly useful for testing or running the examples without a full installation.

Usage

The daxiamcp command-line tool creates a FastMCP server from an OpenAPI specification.

Configuration

Configure the server using the following environment variables:

Variable Default Description
API_BASE_URL https://api-sandbox.daxiaplatform.com/sandbox/api/v1 The base URL of the API
OPENAPI_SPEC_URL http://localhost/local/openapi/daXia1.json The URL of the OpenAPI specification
SERVER_NAME Daxia API The name of the MCP server
DAXIA_AUTH_URL https://auth-sbx.daxiaplatform.com/oauth2/token OAuth2 token endpoint URL
DAXIA_CLIENT_ID (has default) OAuth2 client ID for Daxia authentication
DAXIA_AUTH_BASIC (has default) Base64-encoded Basic auth string for OAuth2 token request

Running the Server

The server automatically retrieves an OAuth2 access token from the Daxia platform on startup. You can customize the configuration by setting environment variables:

Basic Usage (using defaults):

daxiamcp

Custom Configuration:

export API_BASE_URL="http://localhost:3000/v1"
export OPENAPI_SPEC_URL="http://localhost/local/openapi/gal-inq.json"
export SERVER_NAME="Galicia Inquiries API"
daxiamcp

Authentication

The server uses OAuth2 Client Credentials flow to authenticate with the Daxia platform:

  1. On startup, the server requests an access token from DAXIA_AUTH_URL
  2. The token is obtained using the client credentials (DAXIA_CLIENT_ID and DAXIA_AUTH_BASIC)
  3. The access token is automatically included in all API requests as a Bearer token
  4. If token retrieval fails, the server will use INVALID_TOKEN and log an error

Custom OAuth2 Credentials:

export DAXIA_CLIENT_ID="your-client-id"
export DAXIA_AUTH_BASIC="your-base64-encoded-credentials"
export DAXIA_AUTH_URL="https://your-auth-server.com/oauth2/token"
daxiamcp

Examples

The examples directory contains sample configurations for different services. Each example is a JSON file that can be used with MCP-compatible tools.

Example Configuration

Here's an example configuration for the Galicia Inquiries API (examples/gal-mock/gal-inq.json):

{
    "mcpServers": {
        "daXia": {
            "command": "uvx",
            "args": [
                "daxiamcp"
            ],
            "env": {
                "SERVER_NAME": "daXia API",
                "DAXIA_AUTH_URL": "https://auth-sbx.daxiaplatform.com/oauth2/token",
                "DAXIA_CLIENT_ID": "clientid",
                "DAXIA_AUTH_BASIC": "your-base64-encoded-credentials",
                "OPENAPI_SPEC_URL": "http://localhost/local/openapi/daXia1.json",
                "API_BASE_URL": "https://api-sandbox.daxiaplatform.com/sandbox/api/v1"
            }
        }
    }
}

Using Examples

  1. Navigate to the examples directory:

    cd examples/gal-mock
    
  2. Use the configuration with your MCP client:

    • Copy the configuration to your MCP client's configuration file
    • The client will automatically start the server using uvx daxiamcp
    • The server will use the environment variables defined in the env section
  3. Available Examples:

    • gal-mock/gal-inq.json - Galicia Inquiries API example
    • Add more examples as needed for different services

How It Works

The Daxia OpenAPI MCP server follows this workflow:

graph LR
    A[Daxia OAuth2] --> B[Access Token]
    B --> C[HTTP Client]
    D[OpenAPI Spec] --> E[Parse Specification]
    E --> F[Generate MCP Tools]
    C --> G[FastMCP Server]
    F --> G
    G --> H[MCP Client]
    H --> I[API Requests]
    I --> J[Target API]
  1. OAuth2 Authentication: The server retrieves an access token from the Daxia OAuth2 endpoint using client credentials
  2. Specification Loading: The server fetches the OpenAPI specification from the provided URL
  3. Tool Generation: Each API endpoint is converted into an MCP tool with appropriate parameters
  4. Server Initialization: FastMCP server is initialized with the generated tools and authenticated HTTP client
  5. Request Handling: When a tool is invoked, the server makes the corresponding API request with the Bearer token
  6. Response Processing: API responses are formatted and returned to the MCP client

Architecture

  • main.py: Entry point that initializes the FastMCP server
  • OAuth2 Client: Retrieves access tokens from Daxia authentication endpoint
  • OpenAPI Parser: Reads and validates the OpenAPI specification
  • Tool Generator: Creates MCP tools from API endpoints
  • HTTP Client: Handles API requests with Bearer token authentication
  • FastMCP Integration: Manages the MCP protocol communication

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geaicontext-1.0.2.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geaicontext-1.0.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file geaicontext-1.0.2.tar.gz.

File metadata

  • Download URL: geaicontext-1.0.2.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for geaicontext-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4fdec62378512d598b52115b8b5d1906bcb9ceae84a1ad5e593970fcfa0abaca
MD5 3576868f0e522ee2cfc0b4326b24c612
BLAKE2b-256 c7d6b0ff3a3967943695d4b7b02c04dc5ffc8056dfa3b2be26e92411632e967b

See more details on using hashes here.

File details

Details for the file geaicontext-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for geaicontext-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1da07f5d50440703d154135b247733b753a3b8b2d8cb7b5a8a8ff0c15c0934a0
MD5 fb87673dc60476284286dacb4be29527
BLAKE2b-256 cdc2555f2b31239fa0a747df50de32fc932c509afa5e5ab4129a4feae3c398e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page