relayshieldadmin commited on
Commit
7cbab00
·
verified ·
1 Parent(s): 004e527

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +89 -48
app.py CHANGED
@@ -58,10 +58,43 @@ key at https://api.relayshield.net/developers.
58
  """
59
 
60
  import json
 
 
61
 
62
  import gradio as gr
63
  import requests
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  API_BASE_URL = "https://api.relayshield.net"
66
 
67
 
@@ -176,7 +209,7 @@ def check_mcp_server_risk(server_url: str, api_key: str) -> str:
176
  if not server_url:
177
  return _error_result("other", "server_url is required.")
178
  if not api_key:
179
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-mcp-registry-risk")
180
 
181
  data, error = _call("/v1/metered/mcp-registry-risk", {"server_url": server_url}, api_key)
182
  if error:
@@ -208,7 +241,7 @@ def check_prompt_injection_breach(email: str, api_key: str) -> str:
208
  if not email or "@" not in email:
209
  return _error_result("other", "a valid email address is required.")
210
  if not api_key:
211
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-prompt-injection-breach")
212
 
213
  data, error = _call("/v1/metered/prompt-injection-breach", {"email": email}, api_key)
214
  if error:
@@ -244,7 +277,7 @@ def check_tech_stack_cve(tech_stack: str, api_key: str) -> str:
244
  if not stack_list:
245
  return _error_result("other", "tech_stack is required (comma-separated list of products).")
246
  if not api_key:
247
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-tech-stack-cve")
248
 
249
  data, error = _call("/v1/metered/tech-stack-cve", {"tech_stack": stack_list}, api_key)
250
  if error:
@@ -278,7 +311,7 @@ def check_bulk_identity_risk(domain: str, agent_emails: str, api_key: str) -> st
278
  if not domain:
279
  return _error_result("other", "domain is required.")
280
  if not api_key:
281
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-bulk-identity-risk")
282
 
283
  agents = [e.strip() for e in agent_emails.split(",") if e.strip()][:5]
284
 
@@ -315,7 +348,7 @@ def check_oauth_watchlist(email: str, api_key: str) -> str:
315
  if not email or "@" not in email:
316
  return _error_result("other", "a valid email address is required.")
317
  if not api_key:
318
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-oauth-watchlist")
319
 
320
  data, error = _call("/v1/metered/oauth-watchlist", {"email": email}, api_key)
321
  if error:
@@ -349,7 +382,7 @@ def check_supply_chain(vendor_domains: str, api_key: str) -> str:
349
  if not domains:
350
  return _error_result("other", "vendor_domains is required (comma-separated list, up to 10).")
351
  if not api_key:
352
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-supply-chain")
353
 
354
  data, error = _call("/v1/metered/supply-chain", {"vendor_domains": domains}, api_key)
355
  if error:
@@ -382,7 +415,7 @@ def check_session_risk(email: str, api_key: str) -> str:
382
  if not email or "@" not in email:
383
  return _error_result("other", "a valid email address is required.")
384
  if not api_key:
385
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-session-risk")
386
 
387
  data, error = _call("/v1/metered/session-risk", {"email": email}, api_key)
388
  if error:
@@ -416,7 +449,7 @@ def check_nhi_exposure(domain: str, vendor_domains: str, api_key: str) -> str:
416
  if not domain and not domains:
417
  return _error_result("other", "domain or vendor_domains is required.")
418
  if not api_key:
419
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-nhi-exposure")
420
 
421
  payload: dict = {}
422
  if domain:
@@ -457,7 +490,7 @@ def check_secret_scan(domain: str, vendor_domains: str, api_key: str) -> str:
457
  if not domain and not domains:
458
  return _error_result("other", "domain or vendor_domains is required.")
459
  if not api_key:
460
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-secret-scan")
461
 
462
  payload: dict = {}
463
  if domain:
@@ -546,7 +579,7 @@ def check_agent_risk_summary(domain: str, email: str, tech_stack: str, api_key:
546
  highest severity found across them driving the overall outcome.
547
  """
548
  if not api_key:
549
- return _error_result("auth", "api_key is required. Get one at https://api.relayshield.net/developers#ep-agent-risk-summary")
550
  if not domain and not email and not tech_stack:
551
  return _error_result("other", "at least one of domain, email, or tech_stack is required.")
552
 
@@ -631,7 +664,7 @@ def get_stix_indicators(limit: int, api_key: str) -> str:
631
  A structured result with STIX 2.1 Indicator objects as evidence.
632
  """
633
  if not api_key:
634
- return _error_result("auth", "api_key is required (must be a TI subscription key). Get one at https://api.relayshield.net/developers#ti-subscription")
635
 
636
  page_size = limit if limit and 0 < limit <= 2000 else 50
637
  try:
@@ -693,7 +726,7 @@ mcp_risk_tab = gr.Interface(
693
  fn=check_mcp_server_risk,
694
  inputs=[
695
  gr.Textbox(label="MCP Server URL", placeholder="https://example.com/mcp"),
696
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-mcp-registry-risk"),
697
  ],
698
  outputs=gr.Textbox(label="Result"),
699
  title="MCP Server Risk Check",
@@ -704,7 +737,7 @@ breach_tab = gr.Interface(
704
  fn=check_prompt_injection_breach,
705
  inputs=[
706
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
707
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-prompt-injection-breach"),
708
  ],
709
  outputs=gr.Textbox(label="Result"),
710
  title="Prompt-Injection Breach Check",
@@ -715,7 +748,7 @@ tech_stack_tab = gr.Interface(
715
  fn=check_tech_stack_cve,
716
  inputs=[
717
  gr.Textbox(label="Tech Stack (comma-separated)", placeholder="langchain, nacos, minio"),
718
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-tech-stack-cve"),
719
  ],
720
  outputs=gr.Textbox(label="Result"),
721
  title="Tech Stack CVE Check",
@@ -727,7 +760,7 @@ bulk_identity_tab = gr.Interface(
727
  inputs=[
728
  gr.Textbox(label="Domain", placeholder="example.com"),
729
  gr.Textbox(label="Agent Emails (comma-separated, up to 5)", placeholder="ai-agent@example.com, svc@example.com"),
730
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-bulk-identity-risk"),
731
  ],
732
  outputs=gr.Textbox(label="Result"),
733
  title="Bulk Identity Risk Check",
@@ -738,7 +771,7 @@ oauth_watchlist_tab = gr.Interface(
738
  fn=check_oauth_watchlist,
739
  inputs=[
740
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
741
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-oauth-watchlist"),
742
  ],
743
  outputs=gr.Textbox(label="Result"),
744
  title="OAuth Watchlist Check",
@@ -749,7 +782,7 @@ supply_chain_tab = gr.Interface(
749
  fn=check_supply_chain,
750
  inputs=[
751
  gr.Textbox(label="Vendor Domains (comma-separated, up to 10)", placeholder="vendor1.com, vendor2.com"),
752
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-supply-chain"),
753
  ],
754
  outputs=gr.Textbox(label="Result"),
755
  title="Supply Chain Risk Check",
@@ -760,7 +793,7 @@ session_risk_tab = gr.Interface(
760
  fn=check_session_risk,
761
  inputs=[
762
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
763
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-session-risk"),
764
  ],
765
  outputs=gr.Textbox(label="Result"),
766
  title="Session Risk Check",
@@ -772,7 +805,7 @@ nhi_exposure_tab = gr.Interface(
772
  inputs=[
773
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
774
  gr.Textbox(label="Vendor Domains (comma-separated, up to 10, optional)", placeholder="vendor1.com, vendor2.com"),
775
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-nhi-exposure"),
776
  ],
777
  outputs=gr.Textbox(label="Result"),
778
  title="Non-Human Identity Exposure Check",
@@ -784,7 +817,7 @@ secret_scan_tab = gr.Interface(
784
  inputs=[
785
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
786
  gr.Textbox(label="Vendor Domains (comma-separated, up to 5, optional)", placeholder="vendor1.com, vendor2.com"),
787
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-secret-scan"),
788
  ],
789
  outputs=gr.Textbox(label="Result"),
790
  title="Secret Scan Check",
@@ -795,7 +828,7 @@ llm_credential_tab = gr.Interface(
795
  fn=check_llm_credential_exposure,
796
  inputs=[
797
  gr.Textbox(label="Domain", placeholder="example.com"),
798
- gr.Textbox(label="RelayShield API Key (optional — try free, 20 calls/day shared demo)", type="password", placeholder="Leave blank to try for free, or get your own key at api.relayshield.net/developers#ep-llm-credential-exposure"),
799
  ],
800
  outputs=gr.Textbox(label="Result"),
801
  title="LLM Credential Exposure (LLMjacking)",
@@ -808,7 +841,7 @@ agent_risk_summary_tab = gr.Interface(
808
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
809
  gr.Textbox(label="Email Address (optional)", placeholder="agent@example.com"),
810
  gr.Textbox(label="Tech Stack (comma-separated, optional)", placeholder="langchain, nacos"),
811
- gr.Textbox(label="RelayShield API Key", type="password", placeholder="Get one at api.relayshield.net/developers#ep-agent-risk-summary"),
812
  ],
813
  outputs=gr.Textbox(label="Result"),
814
  title="Agent Risk Summary (Composite)",
@@ -853,7 +886,7 @@ demo = gr.TabbedInterface(
853
  # (their scanner returned a 404 during initialization against the plain
854
  # Gradio MCP endpoint — this is Smithery's own documented workaround:
855
  # https://smithery.ai/docs/build/publish#troubleshooting).
856
- _SERVER_CARD = {
857
  "serverInfo": {
858
  "name": "RelayShield Agentic Attack Surface",
859
  "version": "3.0.0",
@@ -1025,29 +1058,37 @@ _SERVER_CARD = {
1025
  "prompts": [],
1026
  }
1027
 
1028
- # On HF's Gradio-SDK Spaces, a Node.js frontend proxy sits in front of the
1029
- # Python process and only forwards a fixed whitelist of paths to it —
1030
- # confirmed via Gradio's own source comment (routes.py) and by observing
1031
- # that even nonexistent paths returned the identical SPA shell as our
1032
- # custom route. No Python-side route can be reached that way. Running this
1033
- # as a Docker SDK Space instead means our own FastAPI app is the only thing
1034
- # HF's proxy talks to, so registering the route on `app` BEFORE mounting
1035
- # Gradio (mounted routes are matched in registration order, so anything
1036
- # added first is checked before Gradio's own catch-all) makes it reachable.
1037
- from fastapi import FastAPI
1038
- from fastapi.responses import JSONResponse
1039
-
1040
- app = FastAPI()
1041
-
1042
-
1043
- @app.get("/.well-known/mcp/server-card.json")
1044
- async def server_card():
1045
- return JSONResponse(_SERVER_CARD)
1046
-
1047
-
1048
- app = gr.mount_gradio_app(app, demo, path="/", mcp_server=True)
1049
-
 
 
 
 
 
 
 
 
 
 
1050
  if __name__ == "__main__":
1051
- import uvicorn
1052
-
1053
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
58
  """
59
 
60
  import json
61
+ import os
62
+ import re
63
 
64
  import gradio as gr
65
  import requests
66
 
67
+ # ---------------------------------------------------------------------------
68
+ # AWS Marketplace mode — added 2026-07-27. This same file is deployed as two
69
+ # separate HF Spaces: the original public Space (this env var unset) keeps
70
+ # directing callers to the public self-serve signup page exactly as before;
71
+ # a second Space (AWS_MARKETPLACE_MODE=true, registered as Bundle D's MCP
72
+ # endpoint URL on AWS Marketplace) scrubs every reference to that page. AWS's
73
+ # Tier-1 audit treats any reachable link to an external payment-collecting
74
+ # page as a violation, even one buried in a tool parameter description
75
+ # rather than the AWS listing text itself — this is what caused Bundle D's
76
+ # visibility request to fail a second time after the listing text itself was
77
+ # already fixed. Keep both Spaces' code identical except for this one env
78
+ # var; redeploy both whenever this file changes.
79
+ # ---------------------------------------------------------------------------
80
+ AWS_MARKETPLACE_MODE = os.environ.get("AWS_MARKETPLACE_MODE", "").lower() == "true"
81
+
82
+ _KEY_URL_RE = re.compile(
83
+ r"(?:Get (?:a(?:\s+key)?|one|your own(?:\s+key)?)|get your own key)\s+at\s+"
84
+ r"(?:https?://)?api\.relayshield\.net/developers(?:#[\w-]+)?\.?",
85
+ )
86
+ _AWS_KEY_TEXT = "Included with your AWS Marketplace subscription, issued automatically by email"
87
+
88
+
89
+ def _scrub(text: str) -> str:
90
+ """No-op unless AWS_MARKETPLACE_MODE is set — see comment above."""
91
+ if not AWS_MARKETPLACE_MODE or not text:
92
+ return text
93
+ return _KEY_URL_RE.sub(_AWS_KEY_TEXT, text)
94
+
95
+
96
+ __doc__ = _scrub(__doc__)
97
+
98
  API_BASE_URL = "https://api.relayshield.net"
99
 
100
 
 
209
  if not server_url:
210
  return _error_result("other", "server_url is required.")
211
  if not api_key:
212
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-mcp-registry-risk"))
213
 
214
  data, error = _call("/v1/metered/mcp-registry-risk", {"server_url": server_url}, api_key)
215
  if error:
 
241
  if not email or "@" not in email:
242
  return _error_result("other", "a valid email address is required.")
243
  if not api_key:
244
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-prompt-injection-breach"))
245
 
246
  data, error = _call("/v1/metered/prompt-injection-breach", {"email": email}, api_key)
247
  if error:
 
277
  if not stack_list:
278
  return _error_result("other", "tech_stack is required (comma-separated list of products).")
279
  if not api_key:
280
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-tech-stack-cve"))
281
 
282
  data, error = _call("/v1/metered/tech-stack-cve", {"tech_stack": stack_list}, api_key)
283
  if error:
 
311
  if not domain:
312
  return _error_result("other", "domain is required.")
313
  if not api_key:
314
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-bulk-identity-risk"))
315
 
316
  agents = [e.strip() for e in agent_emails.split(",") if e.strip()][:5]
317
 
 
348
  if not email or "@" not in email:
349
  return _error_result("other", "a valid email address is required.")
350
  if not api_key:
351
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-oauth-watchlist"))
352
 
353
  data, error = _call("/v1/metered/oauth-watchlist", {"email": email}, api_key)
354
  if error:
 
382
  if not domains:
383
  return _error_result("other", "vendor_domains is required (comma-separated list, up to 10).")
384
  if not api_key:
385
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-supply-chain"))
386
 
387
  data, error = _call("/v1/metered/supply-chain", {"vendor_domains": domains}, api_key)
388
  if error:
 
415
  if not email or "@" not in email:
416
  return _error_result("other", "a valid email address is required.")
417
  if not api_key:
418
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-session-risk"))
419
 
420
  data, error = _call("/v1/metered/session-risk", {"email": email}, api_key)
421
  if error:
 
449
  if not domain and not domains:
450
  return _error_result("other", "domain or vendor_domains is required.")
451
  if not api_key:
452
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-nhi-exposure"))
453
 
454
  payload: dict = {}
455
  if domain:
 
490
  if not domain and not domains:
491
  return _error_result("other", "domain or vendor_domains is required.")
492
  if not api_key:
493
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-secret-scan"))
494
 
495
  payload: dict = {}
496
  if domain:
 
579
  highest severity found across them driving the overall outcome.
580
  """
581
  if not api_key:
582
+ return _error_result("auth", _scrub("api_key is required. Get one at https://api.relayshield.net/developers#ep-agent-risk-summary"))
583
  if not domain and not email and not tech_stack:
584
  return _error_result("other", "at least one of domain, email, or tech_stack is required.")
585
 
 
664
  A structured result with STIX 2.1 Indicator objects as evidence.
665
  """
666
  if not api_key:
667
+ return _error_result("auth", _scrub("api_key is required (must be a TI subscription key). Get one at https://api.relayshield.net/developers#ti-subscription"))
668
 
669
  page_size = limit if limit and 0 < limit <= 2000 else 50
670
  try:
 
726
  fn=check_mcp_server_risk,
727
  inputs=[
728
  gr.Textbox(label="MCP Server URL", placeholder="https://example.com/mcp"),
729
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-mcp-registry-risk")),
730
  ],
731
  outputs=gr.Textbox(label="Result"),
732
  title="MCP Server Risk Check",
 
737
  fn=check_prompt_injection_breach,
738
  inputs=[
739
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
740
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-prompt-injection-breach")),
741
  ],
742
  outputs=gr.Textbox(label="Result"),
743
  title="Prompt-Injection Breach Check",
 
748
  fn=check_tech_stack_cve,
749
  inputs=[
750
  gr.Textbox(label="Tech Stack (comma-separated)", placeholder="langchain, nacos, minio"),
751
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-tech-stack-cve")),
752
  ],
753
  outputs=gr.Textbox(label="Result"),
754
  title="Tech Stack CVE Check",
 
760
  inputs=[
761
  gr.Textbox(label="Domain", placeholder="example.com"),
762
  gr.Textbox(label="Agent Emails (comma-separated, up to 5)", placeholder="ai-agent@example.com, svc@example.com"),
763
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-bulk-identity-risk")),
764
  ],
765
  outputs=gr.Textbox(label="Result"),
766
  title="Bulk Identity Risk Check",
 
771
  fn=check_oauth_watchlist,
772
  inputs=[
773
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
774
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-oauth-watchlist")),
775
  ],
776
  outputs=gr.Textbox(label="Result"),
777
  title="OAuth Watchlist Check",
 
782
  fn=check_supply_chain,
783
  inputs=[
784
  gr.Textbox(label="Vendor Domains (comma-separated, up to 10)", placeholder="vendor1.com, vendor2.com"),
785
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-supply-chain")),
786
  ],
787
  outputs=gr.Textbox(label="Result"),
788
  title="Supply Chain Risk Check",
 
793
  fn=check_session_risk,
794
  inputs=[
795
  gr.Textbox(label="Email Address", placeholder="agent@example.com"),
796
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-session-risk")),
797
  ],
798
  outputs=gr.Textbox(label="Result"),
799
  title="Session Risk Check",
 
805
  inputs=[
806
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
807
  gr.Textbox(label="Vendor Domains (comma-separated, up to 10, optional)", placeholder="vendor1.com, vendor2.com"),
808
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-nhi-exposure")),
809
  ],
810
  outputs=gr.Textbox(label="Result"),
811
  title="Non-Human Identity Exposure Check",
 
817
  inputs=[
818
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
819
  gr.Textbox(label="Vendor Domains (comma-separated, up to 5, optional)", placeholder="vendor1.com, vendor2.com"),
820
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-secret-scan")),
821
  ],
822
  outputs=gr.Textbox(label="Result"),
823
  title="Secret Scan Check",
 
828
  fn=check_llm_credential_exposure,
829
  inputs=[
830
  gr.Textbox(label="Domain", placeholder="example.com"),
831
+ gr.Textbox(label="RelayShield API Key (optional — try free, 20 calls/day shared demo)", type="password", placeholder=_scrub("Leave blank to try for free, or get your own key at api.relayshield.net/developers#ep-llm-credential-exposure")),
832
  ],
833
  outputs=gr.Textbox(label="Result"),
834
  title="LLM Credential Exposure (LLMjacking)",
 
841
  gr.Textbox(label="Domain (optional)", placeholder="example.com"),
842
  gr.Textbox(label="Email Address (optional)", placeholder="agent@example.com"),
843
  gr.Textbox(label="Tech Stack (comma-separated, optional)", placeholder="langchain, nacos"),
844
+ gr.Textbox(label="RelayShield API Key", type="password", placeholder=_scrub("Get one at api.relayshield.net/developers#ep-agent-risk-summary")),
845
  ],
846
  outputs=gr.Textbox(label="Result"),
847
  title="Agent Risk Summary (Composite)",
 
886
  # (their scanner returned a 404 during initialization against the plain
887
  # Gradio MCP endpoint — this is Smithery's own documented workaround:
888
  # https://smithery.ai/docs/build/publish#troubleshooting).
889
+ _SERVER_CARD_RAW = {
890
  "serverInfo": {
891
  "name": "RelayShield Agentic Attack Surface",
892
  "version": "3.0.0",
 
1058
  "prompts": [],
1059
  }
1060
 
1061
+ # Scrub the developers-page reference from the manifest too (no-op in public
1062
+ # mode) — this is served directly at /.well-known/mcp/server-card.json for
1063
+ # directories like Smithery, a separate surface from the live MCP handshake.
1064
+ _SERVER_CARD = json.loads(_scrub(json.dumps(_SERVER_CARD_RAW)))
1065
+
1066
+ # Scrub every tool function's docstring (no-op in public mode) — must happen
1067
+ # before demo.launch() below, since that's the point Gradio reads __doc__ to
1068
+ # build the live MCP tool schema an MCP client actually sees.
1069
+ for _fn in (
1070
+ check_mcp_server_risk, check_prompt_injection_breach, check_tech_stack_cve,
1071
+ check_bulk_identity_risk, check_oauth_watchlist, check_supply_chain,
1072
+ check_session_risk, check_nhi_exposure, check_secret_scan,
1073
+ check_llm_credential_exposure, check_agent_risk_summary,
1074
+ get_stix_indicators, check_server_status,
1075
+ ):
1076
+ if _fn.__doc__:
1077
+ _fn.__doc__ = _scrub(_fn.__doc__)
1078
+
1079
+ # NOTE 2026-07-27: this used to be a custom FastAPI app with
1080
+ # gr.mount_gradio_app(app, demo, path="/", mcp_server=True) plus a manual
1081
+ # uvicorn.run(), which also served a custom /.well-known/mcp/server-card.json
1082
+ # route (Smithery's documented discovery workaround — the original comment
1083
+ # explaining why a Docker SDK Space + custom route was needed at all is in
1084
+ # git history). That combination started throwing "[Errno 98] address
1085
+ # already in use" on every fresh HF Docker build, reproduced identically
1086
+ # even after reverting to the exact byte-for-byte code that had been live
1087
+ # and working for weeks — ruled out as anything in this file specifically.
1088
+ # Suspected cause: the mount_gradio_app(mcp_server=True) code path behaves
1089
+ # differently than the far more common, more-tested demo.launch(mcp_server=
1090
+ # True) path used below. _SERVER_CARD above is temporarily unused as a
1091
+ # result — re-wire the custom route back in once this is confirmed stable
1092
+ # for a while, rather than immediately.
1093
  if __name__ == "__main__":
1094
+ demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True)