-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmcp_server.py
More file actions
69 lines (56 loc) · 1.95 KB
/
Copy pathmcp_server.py
File metadata and controls
69 lines (56 loc) · 1.95 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
"""MCP (Model Context Protocol) server implementation for AutoC."""
from mcp.server.fastmcp import FastMCP
from backend.run import run
mcp = FastMCP("AutoC")
@mcp.tool()
def analyze_security_blog(url: str) -> str:
"""
Analyze a security blog post and extract IoCs, keywords, and Q&A.
Args:
url (str): The URL of the blog post to analyze.
Returns:
str: The analysis result, including detected keywords, Q&A, and IoCs.
"""
try:
res = run(url=url)
output = ""
keywords = res.get("keywords_found")
qna = res.get("qna")
iocs = res.get("iocs_found")
mitre_ttps = res.get("mitre_ttps")
# Keywords
output += f"\n🔍 DETECTED Keywords ({len(keywords)})\n"
if keywords:
tags = ", ".join(f"{keyword}" for keyword in keywords)
output += tags + "\n"
else:
output += "No keywords found\n"
# Q&A
output += f"\n📝 Q&A about the blog\n"
if qna:
for item in qna:
output += f"Q: {item['question']}\nA: {item['answer']}\n"
else:
output += "No Q&A found\n"
# IoCs
output += f"\n⚠️ DETECTED IoCs ({len(iocs)})\n"
if iocs:
for ioc in iocs:
output += f"Type: {ioc['type']}, Value: {ioc['value']}\n"
else:
output += "No IoCs found\n"
# MITRE ATT&CK TTPs Classification
if mitre_ttps is not None:
output += f"\n🧑💻 MITRE TTPs ({len(mitre_ttps)})\n"
if mitre_ttps:
for ttp in mitre_ttps:
output += (
f"ID: {ttp['id']}, Name: {ttp['name']}, URL: {ttp['url']}\n"
)
else:
output += "No MITRE TTPs found\n"
return output
except Exception as e:
return f"Error: {str(e)}"
if __name__ == "__main__":
mcp.run(transport="stdio")