Skip to content

Commit 866d021

Browse files
MoltyCelclaude
andcommitted
feat: add Verified by MolTrust badge system (v1.1.0)
3 new MCP tools: mt_get_badge, mt_issue_badge, mt_check_badge Brings total to 45 tools. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a0560aa commit 866d021

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "moltrust-mcp-server"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
description = "MCP server for MolTrust — Trust Infrastructure for AI Agents"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/moltrust_mcp_server/server.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,120 @@ async def mt_register_seed(
21072107
)
21082108

21092109

2110+
# ---------------------------------------------------------------------------
2111+
# Verified Badge Tools
2112+
# ---------------------------------------------------------------------------
2113+
2114+
2115+
@mcp.tool()
2116+
async def mt_get_badge(
2117+
did: str,
2118+
ctx: Context[ServerSession, MolTrustClient] | None = None,
2119+
) -> str:
2120+
"""Get the Verified by MolTrust badge status for an agent.
2121+
2122+
Returns badge tier, trust score, grade, issue/expiry dates,
2123+
and embeddable SVG URL.
2124+
2125+
Args:
2126+
did: The DID of the agent to check
2127+
"""
2128+
assert ctx is not None
2129+
client = _client(ctx)
2130+
resp = await client.http.get(f"/identity/badge/{did}")
2131+
if resp.status_code != 200:
2132+
return f"Error: {resp.status_code}{resp.text[:200]}"
2133+
data = resp.json()
2134+
if not data.get("verified"):
2135+
return (
2136+
f"Badge Status: Not Verified\n\n"
2137+
f"DID: {data.get('did')}\n"
2138+
f"Trust Score: {data.get('trust_score', 'N/A')}\n"
2139+
f"Grade: {data.get('grade', 'N/A')}\n\n"
2140+
f"Badge URL: {data.get('badge_url')}\n"
2141+
f"Verify: {data.get('verify_url')}"
2142+
)
2143+
return (
2144+
f"Badge Status: {data.get('tier', '').capitalize()}\n\n"
2145+
f"DID: {data.get('did')}\n"
2146+
f"Tier: {data.get('tier')}\n"
2147+
f"Trust Score: {data.get('trust_score')}\n"
2148+
f"Grade: {data.get('grade')}\n"
2149+
f"Issued: {data.get('issued_at')}\n"
2150+
f"Expires: {data.get('expires_at')}\n"
2151+
f"VC Hash: {data.get('vc_hash')}\n\n"
2152+
f"Badge SVG: {data.get('badge_url')}\n"
2153+
f"Verify: {data.get('verify_url')}\n\n"
2154+
f"Embed: [![Verified by MolTrust]({data.get('badge_url')})]({data.get('verify_url')})"
2155+
)
2156+
2157+
2158+
@mcp.tool()
2159+
async def mt_issue_badge(
2160+
did: str,
2161+
tier: str = "verified",
2162+
ctx: Context[ServerSession, MolTrustClient] | None = None,
2163+
) -> str:
2164+
"""Issue a Verified by MolTrust badge for an agent.
2165+
2166+
Tiers: 'verified' (score 40+, $5), 'trusted' (score 60+, $20).
2167+
Badge is valid for 1 year and auto-revokes if trust score drops.
2168+
2169+
Args:
2170+
did: The DID of the agent to issue a badge for
2171+
tier: Badge tier — 'verified' or 'trusted'
2172+
"""
2173+
assert ctx is not None
2174+
client = _client(ctx)
2175+
resp = await client.http.post(
2176+
"/identity/badge/issue",
2177+
json={"did": did, "tier": tier},
2178+
)
2179+
if resp.status_code != 200:
2180+
return f"Error: {resp.status_code}{resp.text[:200]}"
2181+
data = resp.json()
2182+
return (
2183+
f"Badge Issued Successfully\n\n"
2184+
f"DID: {data.get('did')}\n"
2185+
f"Tier: {data.get('tier')}\n"
2186+
f"Trust Score: {data.get('trust_score')}\n"
2187+
f"Issued: {data.get('issued_at')}\n"
2188+
f"Expires: {data.get('expires_at')}\n"
2189+
f"VC Hash: {data.get('vc_hash')}\n\n"
2190+
f"Badge SVG: {data.get('badge_url')}\n"
2191+
f"Verify: {data.get('verify_url')}\n\n"
2192+
f"Embed in README:\n"
2193+
f"[![Verified by MolTrust]({data.get('badge_url')})]({data.get('verify_url')})"
2194+
)
2195+
2196+
2197+
@mcp.tool()
2198+
async def mt_check_badge(
2199+
did: str,
2200+
ctx: Context[ServerSession, MolTrustClient] | None = None,
2201+
) -> str:
2202+
"""Quick check: is this agent badge-verified by MolTrust?
2203+
2204+
Returns a simple yes/no with tier and expiry info.
2205+
2206+
Args:
2207+
did: The DID of the agent to check
2208+
"""
2209+
assert ctx is not None
2210+
client = _client(ctx)
2211+
resp = await client.http.get(f"/identity/badge/check/{did}")
2212+
if resp.status_code != 200:
2213+
return f"Error: {resp.status_code}{resp.text[:200]}"
2214+
data = resp.json()
2215+
if data.get("verified"):
2216+
return (
2217+
f"Verified: YES\n"
2218+
f"Tier: {data.get('tier')}\n"
2219+
f"Expires in: {data.get('expires_in_days')} days"
2220+
)
2221+
return "Verified: NO"
2222+
2223+
21102224
# ---------------------------------------------------------------------------
21112225
# Helpers
21122226
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)