Skip to main content

QWED-MCP Overview

Model Context Protocol (MCP) Server for QWED Verification PyPI version Tests License QWED-MCP brings deterministic verification to Claude Desktop, VS Code, and any MCP-compatible AI assistant. Instead of trusting LLMs to compute correctly, QWED-MCP provides verification tools that use formal methods to guarantee correctness.

Why QWED-MCP?

The Problem

LLMs are powerful but unreliable for:
  • Mathematical calculations - They approximate, don’t compute
  • Logical reasoning - They guess patterns, don’t prove
  • Code security - They miss edge cases, don’t analyze
  • SQL queries - They don’t validate, just generate

The Solution

QWED-MCP gives AI assistants access to deterministic verification tools:
Without QWED-MCPWith QWED-MCP
Claude calculates → 95% correctClaude + verify_math100% correct
Claude writes SQL → might injectClaude + verify_sqlinjection detected
Claude reasons → might be wrongClaude + verify_logicformally proven
Claude codes → might be unsafeClaude + verify_codesecurity checked

How It Works

┌─────────────────────────────────────────────────────────────┐
│                    Your AI Application                       │
│  ┌─────────────────┐        ┌─────────────────────────────┐ │
│  │  Claude Desktop │        │        VS Code + Copilot    │ │
│  │  or any MCP     │        │        or any MCP Client    │ │
│  │  compatible     │        │                             │ │
│  └────────┬────────┘        └──────────────┬──────────────┘ │
└───────────┼─────────────────────────────────┼───────────────┘
            │                                 │
            │         MCP Protocol            │
            │       (JSON-RPC over stdio)     │
            ▼                                 ▼
┌──────────────────────────────────────────────────────────────┐
│                     QWED-MCP Server                          │
├──────────────────────────────────────────────────────────────┤
│                                                              │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐   │
│  │ verify_math  │  │ verify_logic │  │   verify_code    │   │
│  │    Tool      │  │    Tool      │  │      Tool        │   │
│  └──────┬───────┘  └──────┬───────┘  └────────┬─────────┘   │
│         │                 │                    │             │
│  ┌──────▼───────┐  ┌──────▼───────┐  ┌────────▼─────────┐   │
│  │    SymPy     │  │  Z3 Solver   │  │  Python AST      │   │
│  │   Engine     │  │   Engine     │  │   Analysis       │   │
│  └──────────────┘  └──────────────┘  └──────────────────┘   │
│                                                              │
│  ┌──────────────┐                                            │
│  │ verify_sql   │                                            │
│  │    Tool      │                                            │
│  └──────┬───────┘                                            │
│         │                                                    │
│  ┌──────▼───────┐                                            │
│  │   Pattern    │                                            │
│  │   Matching   │                                            │
│  └──────────────┘                                            │
└──────────────────────────────────────────────────────────────┘

Available Tools

ToolEngineUse Case
verify_mathSymPyVerify calculations, derivatives, integrals
verify_logicZ3 SMTProve logical arguments, check validity
verify_codeASTDetect security vulnerabilities in code
verify_sqlPatternSQL injection detection, query validation

Installation

pip install qwed-mcp

From Source

git clone https://github.com/QWED-AI/qwed-mcp.git
cd qwed-mcp
pip install -e .

Verify Installation

qwed-mcp --version
# qwed-mcp 0.1.0

Quick Start

Claude Desktop Setup

  1. Find your config file:
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Add QWED-MCP server:
{
  "mcpServers": {
    "qwed-verification": {
      "command": "qwed-mcp"
    }
  }
}
  1. Restart Claude Desktop
  2. Test it! Ask Claude:
    “What’s the derivative of x^3? Use verify_math to check.”

VS Code Setup

  1. Install MCP extension (if not already)
  2. Add to settings.json:
{
  "mcp.servers": {
    "qwed-verification": {
      "command": "qwed-mcp"
    }
  }
}
  1. Restart VS Code

Python Client

You can also use QWED-MCP programmatically:
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def main():
    server_params = StdioServerParameters(command="qwed-mcp")
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            
            # List available tools
            tools = await session.list_tools()
            print(f"Available tools: {[t.name for t in tools.tools]}")
            
            # Call verify_math
            result = await session.call_tool(
                "verify_math",
                arguments={
                    "expression": "x**2",
                    "claimed_result": "2*x",
                    "operation": "derivative"
                }
            )
            print(result)

asyncio.run(main())

Configuration

Environment Variables

VariableDescriptionDefault
QWED_LOG_LEVELLogging level (DEBUG, INFO, WARNING, ERROR)INFO
QWED_TIMEOUTTool execution timeout in seconds30

Example with Environment Variables

Windows (PowerShell):
$env:QWED_LOG_LEVEL = "DEBUG"
qwed-mcp
macOS/Linux:
QWED_LOG_LEVEL=DEBUG qwed-mcp

Use Cases

1. Financial Calculations

Verify that AI-generated financial calculations are correct:
User: Calculate compound interest for $10,000 at 5% for 3 years

Claude: The compound interest is $1,576.25
        Final amount: $11,576.25
        
        [Calling verify_math to confirm...]
        ✅ VERIFIED: 10000 * (1.05)^3 = 11576.25

2. Research Validation

Ensure scientific claims are logically valid:
User: If all mammals are warm-blooded, and dolphins are mammals,
      are dolphins warm-blooded?

Claude: [Calling verify_logic...]
        ✅ VERIFIED: The conclusion logically follows from the premises
        
        Dolphins are warm-blooded.

3. Secure Coding

Check AI-generated code for security issues:
User: Write a function to execute user commands

Claude: def run_command(cmd):
            os.system(cmd)  # Execute the command
        
        [Calling verify_code...]
        ❌ SECURITY ISSUE: os.system() is dangerous
        
        Here's a safer alternative...

4. SQL Security

Prevent SQL injection in generated queries:
User: Generate a query to find user "admin' OR '1'='1"

Claude: SELECT * FROM users WHERE username = 'admin'' OR ''1''=''1'
        
        [Calling verify_sql...]
        ❌ SQL INJECTION DETECTED: Suspicious tautology pattern