Complete Python SDK for MCPF - Unified interface to all MCPF Trust Framework components: DID/VC, ANS, MCP Registry, and A2A delegation.
The MCPF Python SDK provides a unified, Pythonic interface to the entire MCPF Trust Framework:
from mcpf import MCPF
# Initialize SDK
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
registry_url="https://ans.veritrust.vc/mcp",
a2a_url="https://a2a.example.com"
)
# Resolve agent name β verify credentials β check delegation β execute
agent = await mcpf.resolve_and_verify("fraud-detector.risk.bank.example.agent")
if await mcpf.can_delegate(agent.did, target_did, "analyze"):
result = await execute_task(agent, target_did, task_data)- π DID/VC Management - Create DIDs, issue/verify credentials, manage revocation
- π ANS Client - Resolve agent names, register agents, search directory
- π MCP Registry - Discover trusted MCP servers, verify credentials
- π A2A Delegation - Check delegation permissions, manage policies
- β Complete Verification - End-to-end credential and policy validation
- β‘ Async/Await - Modern async Python with httpx
- π― Type Hints - Full type annotations for better IDE support
- π§ͺ Well Tested - Comprehensive test suite with >90% coverage
pip install mcpf-pythonfrom mcpf import MCPF
# Initialize
mcpf = MCPF()
# Resolve an agent name
agent = await mcpf.ans.resolve("fraud-detector.risk.bank.example.agent")
print(f"Agent DID: {agent.did}")
print(f"Capabilities: {agent.capabilities}")
# Verify agent credential
is_valid = await mcpf.did.verify_credential(agent.credential_url)
print(f"Credential valid: {is_valid}")
# Check delegation permission
can_delegate = await mcpf.a2a.check_delegation(
from_did="did:web:agent1.example",
to_did="did:web:agent2.example",
action="analyze"
)
print(f"Delegation allowed: {can_delegate.allowed}")from mcpf import MCPF
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
registry_url="https://ans.veritrust.vc/mcp",
a2a_url="https://a2a.example.com",
did_resolver_url="https://resolver.example.com"
)
# Unified operations
agent = await mcpf.resolve_and_verify(agent_name)
can_delegate = await mcpf.can_delegate(from_did, to_did, action)
server = await mcpf.find_mcp_server(capability="weather")from mcpf.did import DIDManager, VCIssuer, VCVerifier
# DID operations
did_manager = DIDManager()
did = did_manager.create_did(method="web", domain="example.com")
did_doc = await did_manager.resolve_did(did)
# Issue credentials
issuer = VCIssuer(
issuer_did="did:web:veritrust.vc",
private_key=private_key
)
credential = issuer.issue_credential(
subject_did="did:web:agent.example",
credential_type="AgentOwnershipCredential",
claims={"permissions": ["query", "analyze"]}
)
# Verify credentials
verifier = VCVerifier()
result = await verifier.verify_credential(credential)
print(f"Valid: {result.valid}")
print(f"Revoked: {result.is_revoked}")from mcpf.ans import ANSClient
ans = ANSClient("https://ans.veritrust.vc")
# Resolve agent name
agent_card = await ans.resolve(
name="fraud-detector.risk.bank.example.agent",
version="1.0.0" # Optional
)
# Register agent
await ans.register(
name="my-agent.company.example.agent",
version="1.0.0",
did="did:web:company.example:agent:my-agent",
provider="My Company",
capabilities=["query", "analyze"],
endpoints={
"agent": "https://company.example/agent",
"presentations": "https://company.example/agent/vp"
}
)
# Search agents
results = await ans.search(capability="fraud-detection")from mcpf.registry import MCPRegistry
registry = MCPRegistry("https://ans.veritrust.vc/mcp")
# List MCP servers
servers = await registry.list_servers(page=1, limit=50)
# Get server by DID
server = await registry.get_server("did:web:weather.example.com:mcp:api")
# Search by capability
weather_servers = await registry.search(capability="getCurrentWeather")
# Register MCP server
await registry.register_server(
did="did:web:myapi.example.com:mcp",
endpoint="https://myapi.example.com/mcp",
manifest="https://myapi.example.com/mcp/manifest.json",
credentials=[...],
metadata={
"capabilities": ["query", "analyze"],
"organization": "My Company",
"country": "US"
}
)from mcpf.a2a import A2ARegistry
a2a = A2ARegistry("https://a2a.example.com")
# Check delegation permission
result = await a2a.check_delegation(
from_did="did:web:fraud-detector.bank.example",
to_did="did:web:risk-analyzer.bank.example",
action="analyze"
)
if result.allowed:
print(f"Delegation allowed: {result.policy}")
else:
print(f"Delegation denied: {result.reason}")
# Register delegation policy
policy = await a2a.register_policy(
from_agent="did:web:agent1.example",
to_agent="did:web:agent2.example",
allowed_actions=["query", "analyze"],
constraints={
"maxDuration": 3600,
"scope": ["transaction-data"]
},
issued_by="did:web:example.com",
valid_from="2025-01-01T00:00:00Z",
valid_until="2026-01-01T00:00:00Z"
)
# Get audit log
audit = await a2a.get_audit_log(
from_did="did:web:agent1.example",
start_date="2025-01-01"
)import asyncio
from mcpf import MCPF
async def verify_agent_chain():
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
registry_url="https://ans.veritrust.vc/mcp"
)
# 1. Resolve agent name to DID
agent = await mcpf.ans.resolve("fraud-detector.risk.bank.example.agent")
print(f"β Resolved: {agent.name} β {agent.did}")
# 2. Get DID document
did_doc = await mcpf.did.resolve_did(agent.did)
print(f"β DID Document: {len(did_doc.verification_method)} keys")
# 3. Verify agent credential
verification = await mcpf.did.verify_credential_url(agent.credential_url)
print(f"β Credential valid: {verification.valid}")
print(f"β Not revoked: {not verification.is_revoked}")
# 4. Check all verifications passed
if verification.valid and not verification.is_revoked:
print("β
Agent fully verified!")
return agent
else:
print("β Agent verification failed")
return None
asyncio.run(verify_agent_chain())import asyncio
from mcpf import MCPF
async def delegation_workflow():
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
a2a_url="https://a2a.example.com"
)
# Resolve both agents
from_agent = await mcpf.ans.resolve("fraud-detector.risk.bank.example.agent")
to_agent = await mcpf.ans.resolve("risk-analyzer.analytics.bank.example.agent")
# Verify both agents
from_valid = await mcpf.did.verify_agent(from_agent.did)
to_valid = await mcpf.did.verify_agent(to_agent.did)
if not (from_valid and to_valid):
print("β Agent verification failed")
return
# Check delegation permission
delegation = await mcpf.a2a.check_delegation(
from_did=from_agent.did,
to_did=to_agent.did,
action="analyze"
)
if delegation.allowed:
print(f"β
Delegation allowed")
print(f" Policy: {delegation.policy.id}")
print(f" Constraints: {delegation.policy.constraints}")
# Execute delegation
result = await execute_analysis(from_agent, to_agent, data)
print(f"β
Task completed: {result}")
else:
print(f"β Delegation denied: {delegation.reason}")
asyncio.run(delegation_workflow())import asyncio
from mcpf import MCPF
async def find_weather_server():
mcpf = MCPF(registry_url="https://ans.veritrust.vc/mcp")
# Search for weather servers
servers = await mcpf.registry.search(
capability="getCurrentWeather",
country="US"
)
print(f"Found {len(servers.items)} weather servers:")
for server in servers.items:
print(f"\n Server: {server.did}")
print(f" Endpoint: {server.endpoint}")
print(f" Organization: {server.metadata.organization}")
print(f" Capabilities: {', '.join(server.metadata.capabilities)}")
# Verify server credential
if server.credentials:
cred = server.credentials[0]
verification = await mcpf.did.verify_credential_url(cred.credential_url)
print(f" Verified: {'β' if verification.valid else 'β'}")
asyncio.run(find_weather_server())import asyncio
from mcpf import MCPF
async def complete_workflow():
"""Complete MCPF workflow: resolve β verify β check delegation β execute"""
mcpf = MCPF(
ans_url="https://ans.veritrust.vc",
registry_url="https://ans.veritrust.vc/mcp",
a2a_url="https://a2a.example.com"
)
# 1. Resolve agent names
print("1οΈβ£ Resolving agent names...")
from_agent = await mcpf.ans.resolve("fraud-detector.risk.bank.example.agent")
to_agent = await mcpf.ans.resolve("risk-analyzer.analytics.bank.example.agent")
# 2. Verify credentials
print("2οΈβ£ Verifying credentials...")
from_valid = await mcpf.did.verify_agent(from_agent.did)
to_valid = await mcpf.did.verify_agent(to_agent.did)
if not (from_valid and to_valid):
print("β Credential verification failed")
return
# 3. Check if MCP server is registered (if using MCP)
print("3οΈβ£ Checking MCP registry...")
try:
mcp_server = await mcpf.registry.get_server(to_agent.did)
print(f" β MCP server registered: {mcp_server.endpoint}")
except:
print(" βΉοΈ Not an MCP server")
# 4. Check delegation permission
print("4οΈβ£ Checking delegation permission...")
delegation = await mcpf.a2a.check_delegation(
from_did=from_agent.did,
to_did=to_agent.did,
action="analyze"
)
if not delegation.allowed:
print(f"β Delegation denied: {delegation.reason}")
return
print(f" β Delegation allowed (policy: {delegation.policy.id})")
# 5. Execute task
print("5οΈβ£ Executing task...")
result = {
"from_agent": from_agent.name,
"to_agent": to_agent.name,
"action": "analyze",
"status": "success"
}
print("β
Workflow complete!")
return result
asyncio.run(complete_workflow())# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# With coverage
pytest --cov=mcpf_python --cov-report=html
# Type checking
mypy mcpf_python
# Linting
ruff check mcpf_pythonFull documentation available at https://mcpf.dev/docs/python
# ANS endpoint
MCPF_ANS_URL=https://ans.veritrust.vc
# MCP Registry endpoint
MCPF_REGISTRY_URL=https://ans.veritrust.vc/mcp
# A2A Registry endpoint
MCPF_A2A_URL=https://a2a.example.com
# DID Resolver
MCPF_DID_RESOLVER_URL=https://resolver.example.com
# Timeouts
MCPF_TIMEOUT=30from mcpf import MCPF, MCPFConfig
config = MCPFConfig(
ans_url="https://ans.veritrust.vc",
registry_url="https://ans.veritrust.vc/mcp",
a2a_url="https://a2a.example.com",
timeout=30,
verify_ssl=True
)
mcpf = MCPF(config=config)See CONTRIBUTING.md for guidelines.
MIT License - see LICENSE
- Website: https://mcpf.dev
- GitHub: https://github.com/MCPTrustFramework/MCPF-python
- Issues: https://github.com/MCPTrustFramework/MCPF-python/issues
- PyPI: https://pypi.org/project/mcpf-python/
- MCPF-specification - SSOT
- MCPF-did-vc - DID/VC infrastructure
- MCPF-ans - Agent Name Service
- MCPF-registry - MCP Trust Registry
- MCPF-a2a-registry - A2A delegation
Version: 1.0.0-alpha
Last Updated: December 31, 2025
Status: Production-ready