Other AI Agents Integration
This guide covers integrating AIVory Guard with any AI coding assistant, whether it supports MCP (Model Context Protocol) or requires a custom API integration.
- MCP Integration is the easiest method for compatible tools
- REST API available for custom integrations
- Python and JavaScript code examples included
- 5 MCP tools available: scan, batch_scan, get_config, get_rules, health_check
Prerequisites
Before you begin:
- Install AIVory Guard
- Have your AIVory API token from app.aivory.net/tokens
- Understanding of your AI tool’s integration capabilities
Integration Options
AIVory Guard supports three integration methods. Choose based on your tool’s capabilities:
MCP Integration
What is MCP?
The Model Context Protocol (MCP) is a standardized protocol for AI agents to communicate with external tools and services. Learn more at modelcontextprotocol.io.
Supported Tools
AIVory Guard’s MCP server works with any MCP-compatible client:
Generic MCP Configuration
Most MCP clients use a JSON configuration file. The exact location varies by tool, but the format is standard:
{
"mcpServers": {
"aivory": {
"command": "npx",
"args": ["@aivorynet/guard"],
"env": {
"AIVORY_API_KEY": "your_api_key_here"
}
}
}
}
Common Configuration Locations
| Tool | Config File Location |
|---|---|
| Claude Code | ~/.config/claude/mcp.json |
| Cursor | .cursor/mcp.json (project root) |
| Continue.dev | .continue/config.json |
| Custom | Tool-specific (check docs) |
Using npx vs Global Install
With npx (recommended):
{
"mcpServers": {
"aivory": {
"command": "npx",
"args": ["@aivorynet/guard"],
"env": {
"AIVORY_API_KEY": "your_key"
}
}
}
}
With global install:
{
"mcpServers": {
"aivory": {
"command": "aivory-guard",
"args": [],
"env": {
"AIVORY_API_KEY": "your_key"
}
}
}
}
Environment Variables
Customize behavior with environment variables:
{
"mcpServers": {
"aivory": {
"command": "npx",
"args": ["@aivorynet/guard"],
"env": {
"AIVORY_API_KEY": "your_key",
"AIVORY_SERVER_URL": "https://app.aivory.net",
"AIVORY_TIMEOUT": "30000"
}
}
}
}
Direct API Integration
If your tool doesn’t support MCP, integrate with AIVory’s REST API.
API Endpoints
Base URL: https://app.aivory.net
Endpoints:
- POST /api/scan - Scan code for violations
- POST /api/batch-scan - Batch scan multiple files
- GET /api/config - Get compliance configuration
- GET /api/rules - List compliance rules
- GET /api/health - Health check
Authentication
All requests require Bearer token authentication:
Authorization: Bearer your_aivory_api_key
Python Example
import requests
AIVORY_BASE_URL = "https://app.aivory.net"
AIVORY_API_KEY = "your_aivory_api_key"
def scan_code(code, language, filename="main.py"):
"""Scan code using AIVory Guard API"""
headers = {
"Authorization": f"Bearer {AIVORY_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"code": code,
"language": language,
"filename": filename,
"standards": ["OWASP", "GDPR", "HIPAA", "SOC2"]
}
response = requests.post(
f"{AIVORY_BASE_URL}/api/scan",
headers=headers,
json=payload,
timeout=30
)
return response.json()
# Usage
result = scan_code(
code="def login(user, pwd): return user == pwd",
language="python"
)
print(f"Violations: {len(result.get('violations', []))}")
JavaScript Example
const AIVORY_BASE_URL = 'https://app.aivory.net';
const AIVORY_API_KEY = process.env.AIVORY_API_KEY;
async function scanCode(code, language, filename = 'main.js') {
const response = await fetch(`${AIVORY_BASE_URL}/api/scan`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${AIVORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
code,
language,
filename,
standards: ['OWASP', 'GDPR', 'PCI-DSS']
})
});
return await response.json();
}
// Usage
const result = await scanCode(
'function auth(u, p) { return u === p; }',
'javascript'
);
console.log('Violations:', result.violations?.length || 0);
Custom Wrapper Integration
Build a custom integration for your specific tool:
Step 1: Define Interface
class AIVoryGuardWrapper:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://app.aivory.net"
def scan(self, code, language):
"""Main scanning method"""
return self._call_api("/api/scan", {
"code": code,
"language": language
})
def batch_scan(self, files):
"""Batch scanning method"""
return self._call_api("/api/batch-scan", {
"files": files
})
def get_config(self):
"""Get compliance configuration"""
return self._call_api("/api/config", method="GET")
def _call_api(self, endpoint, data=None, method="POST"):
import requests
headers = {"Authorization": f"Bearer {self.api_key}"}
if method == "GET":
response = requests.get(
f"{self.base_url}{endpoint}",
headers=headers
)
else:
headers["Content-Type"] = "application/json"
response = requests.post(
f"{self.base_url}{endpoint}",
headers=headers,
json=data
)
return response.json()
Step 2: Integrate with Your Tool
# Example: Integrate with custom AI tool
from your_ai_tool import YourAITool
ai_tool = YourAITool()
aivory = AIVoryGuardWrapper(api_key="your_key")
# Generate code with your AI tool
code = ai_tool.generate_code("Create a login function")
# Scan with AIVory
scan_result = aivory.scan(code, language="python")
# Present results
if scan_result.get("violations"):
print("Violations found! Fixing...")
fixed_code = ai_tool.fix_code(code, scan_result["violations"])
print("Fixed code:", fixed_code)
else:
print("Code is compliant!")
Specific Tool Examples
Continue.dev (VS Code Extension)
Edit .continue/config.json:
{
"mcpServers": [
{
"name": "aivory",
"command": "npx",
"args": ["@aivorynet/guard"],
"env": {
"AIVORY_API_KEY": "your_key"
}
}
]
}
Custom Python Agent
class CustomAgent:
def __init__(self):
self.aivory = AIVoryGuardWrapper(api_key=os.getenv("AIVORY_API_KEY"))
def generate_secure_code(self, prompt):
# Your code generation logic
code = self.generate(prompt)
# Scan with AIVory
result = self.aivory.scan(code, language="python")
return {
"code": code,
"compliant": len(result.get("violations", [])) == 0,
"scan_result": result
}
Available MCP Tools
When using MCP integration, your agent gets access to these tools:
Testing Your Integration
After configuring, test the integration:
# Test AIVory Guard directly
npx @aivorynet/guard test
# Expected output:
# Configuration loaded
# Server: https://app.aivory.net
# Backend is healthy
# Compliance scan completed
Troubleshooting
MCP Server Not Starting
Solutions:
- Verify JSON syntax in config file
- Check Node.js 18+ is installed
- Ensure
npxis in PATH - Check tool-specific logs
API Authentication Errors
Solutions:
- Verify API key starts with
aiv_ - Generate new token at app.aivory.net/tokens
- Check for spaces in the API key value
- Ensure Bearer token format in API calls
Connection Timeouts
Solutions:
- Increase timeout in config (default: 30000ms)
- Check internet connectivity
- Verify firewall isn’t blocking app.aivory.net
- Try switching networks
Best Practices
Need Help?
Can’t find integration instructions for your specific tool?