π¦
Chatgpt Connector
Chatgpt connector for Kruncher
0 installs
Trust: 34 β Low
Ai
Ask AI about Chatgpt Connector
Powered by Claude Β· Grounded in docs
I know everything about Chatgpt Connector. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
AI Tool Infrastructure
A Python library for quickly creating MCP (Model Context Protocol) servers with enterprise features like audit logging, policy enforcement, and state management.
Quick Start
Create an MCP server in under 30 lines:
from ai_tool_infra import (
ExecutionEngine, ToolRegistry, PolicyEngine,
AuditLog, StateManager, tool,
)
from ai_tool_infra.adapters.mcp import MCPAdapter, create_mcp_server
# Define a tool
@tool(name="greet", description="Greet a user")
async def greet(name: str) -> str:
return f"Hello, {name}!"
# Build infrastructure
registry = ToolRegistry()
engine = ExecutionEngine(registry, PolicyEngine(), AuditLog(), StateManager())
registry.register(greet)
# Create and run MCP server
adapter = MCPAdapter(engine, registry)
mcp = create_mcp_server(adapter, "my-server")
mcp.run(transport="sse", host="0.0.0.0", port=8000)
Installation
# Using uv
uv add ai-tool-infra
# With server dependencies
uv add "ai-tool-infra[server]"
# For development
uv add "ai-tool-infra[dev]"
Architecture
AI Tool Infrastructure
βββ Core Layer
β βββ ToolContract # Define tool behavior, side effects, costs
β βββ ToolRegistry # Register and discover tools
β βββ ExecutionEngine # Execute tools with policy/audit/state
β βββ AuditLog # Track all tool executions
β βββ StateManager # Manage execution state
βββ Auth Layer
β βββ PolicyEngine # RBAC, permissions, rate limits
βββ Adapters
β βββ MCPAdapter # Expose tools via MCP protocol
β βββ RESTAdapter # Expose tools via REST API
βββ Connectors
βββ BaseConnector # Base class for API connectors
βββ KruncherConnector # Example: Kruncher API connector
Features
Tool Contracts
Define tools with rich metadata:
from ai_tool_infra import ToolContract, SideEffect, CostHint
tool = ToolContract(
name="create_user",
description="Create a new user",
input_schema={...},
handler=create_user_handler,
side_effect=SideEffect.WRITE, # Declares write operation
idempotent=False, # Not safe to retry
cost_hint=CostHint.EXPENSIVE, # Requires confirmation
required_permissions=["users:write"],
tags=["users", "write"],
)
Custom Connectors
Create connectors for any API:
from ai_tool_infra.connectors.base import BaseConnector, ConnectorConfig
class MyAPIConnector(BaseConnector):
async def health_check(self) -> ConnectorHealth:
return ConnectorHealth(healthy=True, message="OK")
def get_tools(self) -> list[ToolContract]:
return [
ToolContract(name="my_tool", handler=self._my_handler, ...),
]
async def _my_handler(self, **kwargs) -> dict:
return {"result": "success"}
Policy Enforcement
Control access with RBAC:
from ai_tool_infra import PolicyEngine, PolicyRule, User, Role
policy = PolicyEngine()
policy.add_rule(PolicyRule(
permissions=["projects:write"],
roles=[Role.ADMIN, Role.EDITOR],
))
Project Structure
ai-tool-infra/
βββ ai_tool_infra/ # Main library
β βββ adapters/ # Protocol adapters (MCP, REST)
β βββ auth/ # Authentication & authorization
β βββ connectors/ # API connectors
β βββ core/ # Core infrastructure
β βββ utils/ # Utilities
βββ examples/ # Example scripts
β βββ quick_start.py # Minimal example
β βββ demo_server.py # Full Kruncher demo
β βββ custom_connector.py # Custom connector example
βββ tests/ # Test suite
βββ pyproject.toml
Examples
Run Quick Start
uv run python examples/quick_start.py
Run Kruncher Demo
# Set environment variables
export KRUNCHER_API_KEY=your_api_key
# Run server
uv run python examples/demo_server.py
Run Custom Connector Example
uv run python examples/custom_connector.py
Connecting to ChatGPT
- Start the MCP server (e.g.,
uv run python examples/demo_server.py) - Expose via ngrok:
ngrok http 8000 - In ChatGPT: Settings β Connectors β Add Connector
- Enter the ngrok URL:
https://your-url.ngrok.io/sse
Environment Variables
# Required for Kruncher connector
KRUNCHER_API_KEY=your_api_key
KRUNCHER_API_URL=https://api.kruncher.ai/api/integration/project
# Server configuration
HOST=0.0.0.0
PORT=8000
# Optional
LOG_LEVEL=INFO
