Labsco
phuihock logo

DeepInfra API

β˜… 2

from phuihock

Provides a full suite of AI tools via DeepInfra’s OpenAI-compatible API, including image generation, text processing, embeddings, and speech recognition.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredNeeds API keys

MCP DeepInfra AI Tools Server

This is a Model Context Protocol (MCP) server that provides various AI capabilities using the DeepInfra OpenAI-compatible API, including image generation, text processing, embeddings, speech recognition, and more.

Project Structure

mcp-deepinfra/
β”œβ”€β”€ src/
β”‚   └── mcp_deepinfra/
β”‚       β”œβ”€β”€ __init__.py      # Package initialization
β”‚       └── server.py        # Main MCP server implementation
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ conftest.py          # Pytest fixtures and configuration
β”‚   β”œβ”€β”€ test_server.py      # Server initialization tests
β”‚   └── test_tools.py        # Individual tool tests
β”œβ”€β”€ pyproject.toml           # Project configuration and dependencies
β”œβ”€β”€ uv.lock                  # Lock file for uv package manager
β”œβ”€β”€ run_tests.sh             # Convenience script for running tests
└── README.md               # This file

Using with MCP Clients

Configure your MCP client (e.g., Claude Desktop) to use this server.

For Claude Desktop, add to your claude_desktop_config.json:

{
  "mcpServers": {
    "deepinfra": {
      "command": "uv",
      "args": ["run", "mcp_deepinfra"],
      "env": {
        "DEEPINFRA_API_KEY": "your_api_key_here"
      }
    }
  }
}

Tools Provided

This server provides the following MCP tools:

  • generate_image: Generate an image from a text prompt. Returns the URL of the generated image.
  • text_generation: Generate text completion from a prompt.
  • embeddings: Generate embeddings for a list of input texts.
  • speech_recognition: Transcribe audio from a URL to text using Whisper model.
  • zero_shot_image_classification: Classify an image into provided candidate labels using vision model.
  • object_detection: Detect and describe objects in an image using multimodal model.
  • image_classification: Classify and describe contents of an image using multimodal model.
  • text_classification: Analyze text for sentiment and category.
  • token_classification: Perform named entity recognition (NER) on text.
  • fill_mask: Fill masked tokens in text with appropriate words.

Testing

To test the server locally, run the pytest test suite:

# Install test dependencies
uv sync --extra test

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run specific test file
pytest tests/test_tools.py

# Use the convenience script
./run_tests.sh

The tests include:

  • Server initialization and tool listing
  • Individual tool functionality tests via JSON-RPC protocol
  • All tests run synchronously without async/await complexity