-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_from_mcp.py
More file actions
128 lines (107 loc) · 3.83 KB
/
Copy pathmigrate_from_mcp.py
File metadata and controls
128 lines (107 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""Migration guide: MCP tools -> ASPL capabilities.
This example shows how to take existing MCP tool definitions
and register them as ASPL capabilities, gaining trust scoring,
security scanning, and intent-based discovery — while keeping
the MCP bridge so original tool calling still works.
"""
from aspl.adapters.mcp import MCPAdapter
adapter = MCPAdapter()
# --- Step 1: Define your MCP tools (or fetch from your MCP server) ---
my_mcp_tools = [
{
"name": "search_web",
"description": "Search the web using DuckDuckGo API",
"inputSchema": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"},
"max_results": {"type": "integer", "default": 10},
},
"required": ["query"],
},
"annotations": {"readOnlyHint": True},
},
{
"name": "write_file",
"description": "Write content to a file on disk",
"inputSchema": {
"type": "object",
"properties": {
"path": {"type": "string"},
"content": {"type": "string"},
},
"required": ["path", "content"],
},
"annotations": {"destructiveHint": True, "readOnlyHint": False},
},
{
"name": "run_sql",
"description": "Execute a SQL query against the database",
"inputSchema": {
"type": "object",
"properties": {
"query": {"type": "string"},
"database": {"type": "string", "default": "main"},
},
"required": ["query"],
},
"annotations": {"readOnlyHint": False, "openWorldHint": True},
},
]
# --- Step 2: Convert to ASPL capabilities ---
my_server_url = "https://my-mcp-server.example.com"
capabilities = adapter.convert_server(my_server_url, my_mcp_tools)
for cap in capabilities:
print(f"Tool: {cap.source_ref}")
print(f" ASPL Intent: {cap.intent}")
print(f" Safety Level: {cap.safety_level}")
print(f" Tags: {cap.intent_tags}")
print()
# --- Step 3: Publish to ASPL server ---
print("To publish to a running ASPL server:")
print("""
import requests
# Register as an agent first
# (see quickstart.py)
# Then ingest all tools in one call:
response = requests.post(
"http://localhost:5010/v1/ingest/mcp",
headers={"X-API-Key": api_key},
json={
"server_url": "https://my-mcp-server.example.com",
"tools": my_mcp_tools,
}
)
# Each tool now has:
# - Trust score (starts at 0.5 for MCP imports)
# - Security scan results
# - Intent-based discoverability
# - Shop signature for verification
# - MCP bridge so it can still call the original endpoint
""")
# --- What you gain ---
print("""
What MCP tools gain from ASPL:
1. TRUST SCORING
MCP: No trust. You call a tool and hope it works.
ASPL: Every tool gets a Bayesian trust score that updates
with each confirmed use. Bad tools lose trust.
2. SECURITY SCANNING
MCP: No content scanning. Tools can contain anything.
ASPL: Every tool is scanned for prompt injection,
data exfiltration, and resource abuse patterns.
3. INTENT DISCOVERY
MCP: You need to know the exact tool name.
ASPL: Describe what you need in natural language.
"I need to search the web" finds search_web.
4. ENVIRONMENT VERIFICATION
MCP: No env checks. Tool might not work in your runtime.
ASPL: Tools declare requirements. ASPL verifies compatibility.
5. REVOCATION
MCP: No revocation. Bad tools live forever.
ASPL: Compromised tools are revoked instantly via broadcast.
What you keep:
- Original MCP tool calling still works (via bridge adapter)
- No changes to your MCP server needed
- Gradual migration — adopt ASPL features at your own pace
""")