Skip to main content

MCP Tools for AI Cogence - Expose AI capabilities via Model Context Protocol

Project description

AI Cogence MCP Tools

Expose AI Cogence capabilities as MCP (Model Context Protocol) tools that can be used in Claude Desktop and other MCP clients.

What is This?

This package provides 6 AI tools that you can use in MCP-compatible applications:

  • rag_query - AI-powered Q&A with sources
  • semantic_search - Vector similarity search
  • list_chat_sessions - Session management
  • get_session_messages - Message history
  • get_analytics - Usage metrics
  • search_knowledge_base - Keyword search

Installation

pip install ai-cogence-tools

Configuration

Create a .env file with your backend credentials:

POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
POSTGRES_HOST=your_host
POSTGRES_PORT=5432
POSTGRES_DB=your_db
OPENAI_API_KEY=sk-...

Usage with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on Mac):

{
  "mcpServers": {
    "ai-cogence-tools": {
      "command": "ai-cogence-tools",
      "env": {
        "POSTGRES_USER": "your_user",
        "POSTGRES_PASSWORD": "your_password",
        "POSTGRES_HOST": "your_host",
        "POSTGRES_DB": "your_db",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

Restart Claude Desktop. The tools will appear in the tools menu.

Usage Programmatically

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Connect to the server
server_params = StdioServerParameters(
    command="ai-cogence-tools",
    env={
        "POSTGRES_USER": "your_user",
        "POSTGRES_PASSWORD": "your_password",
        # ... other env vars
    }
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # Initialize
        await session.initialize()
        
        # List available tools
        tools = await session.list_tools()
        print(f"Available tools: {[tool.name for tool in tools.tools]}")
        
        # Call a tool
        result = await session.call_tool("rag_query", {
            "question": "What is RAG?"
        })
        print(result.content)

Available Tools

rag_query

Execute a RAG query to get AI-powered answers with sources.

Arguments:

  • question (required): The question to ask
  • session_id (optional): Session ID for conversation context

semantic_search

Perform semantic search using vector embeddings.

Arguments:

  • query (required): Search query
  • top_k (optional, default=5): Number of results

list_chat_sessions

List all chat sessions with metadata.

Arguments:

  • limit (optional, default=20): Maximum sessions to return

get_session_messages

Get all messages for a specific session.

Arguments:

  • session_id (required): Session ID

get_analytics

Get usage analytics and metrics.

Arguments:

  • time_range (optional, default="today"): Time range (today, week, month, all)

search_knowledge_base

Search the knowledge base using keywords.

Arguments:

  • query (required): Search query
  • limit (optional, default=10): Maximum results

How It Works

This MCP server connects to the AI Cogence backend and exposes its capabilities as tools. It:

  1. Uses existing backend services (no code duplication)
  2. Connects to your PostgreSQL database with pgvector
  3. Uses OpenAI for embeddings and completions
  4. Provides RAG, search, and analytics capabilities

Requirements

  • Python 3.10+
  • PostgreSQL with pgvector extension
  • OpenAI API key
  • Access to AI Cogence backend database

License

MIT

Support

For issues or questions, visit: https://github.com/ai-cogence/mcp-tools/issues

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

ai_cogence_tools-1.0.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

ai_cogence_tools-1.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file ai_cogence_tools-1.0.0.tar.gz.

File metadata

  • Download URL: ai_cogence_tools-1.0.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ai_cogence_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2d47117efec716da0d3b68d0c79761ba2cc605e21454866a9d739075df0ed9fe
MD5 75150626c43edd8154a20160adf7e49a
BLAKE2b-256 021b7ef569632c7023508b827642d6fa6c81900d1f4a221c0c184fb262cb60e2

See more details on using hashes here.

File details

Details for the file ai_cogence_tools-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_cogence_tools-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caaa35b9d1c6d01503a629ef1d2c4f844436882d25a9838571879f9f2611d7cf
MD5 a95e9cdf89d3ffaedf1a3bcefc7ae1ee
BLAKE2b-256 47f8c6fc4399800583965db9a13be12577b3a9504cece2dc8e9f34cf3fd3d277

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