MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / detect_framework

Method detect_framework

backend/analyzer.py:249–275  ·  view source on GitHub ↗

Detect workflow framework from actual imports

(code: str, file_path: str)

Source from the content-addressed store, hash-verified

247
248 @staticmethod
249 def detect_framework(code: str, file_path: str) -> str | None:
250 """Detect workflow framework from actual imports"""
251
252 # Check for specific frameworks first
253 for framework, patterns in StaticAnalyzer.FRAMEWORK_PATTERNS.items():
254 if any(re.search(pattern, code) for pattern in patterns):
255 return framework
256
257 # Detect generic LLM usage and identify the client
258 if re.search(r"from\s+openai\s+import|import\s+openai|OpenAI\s*\(", code):
259 return "openai"
260 if re.search(r"from\s+anthropic\s+import|import\s+anthropic|Anthropic\s*\(", code):
261 return "anthropic"
262 if re.search(r"import\s+google\.generativeai|from\s+google\s+import\s+genai|genai\.Client|GoogleGenerativeAI", code):
263 return "gemini"
264 if re.search(r"from\s+ollama\s+import|import\s+ollama", code):
265 return "ollama"
266 if re.search(r"from\s+llama_cpp\s+import|import\s+llama_cpp|from\s+gguf\s+import|from\s+ctransformers\s+import", code):
267 return "llama-cpp"
268 if re.search(r"@modelcontextprotocol/sdk|from\s+mcp\.server|from\s+mcp\s+import|from\s+fastmcp\s+import|McpServer\s*\(|MCPServer\s*\(|FastMCP\s*\(|mcp-go|modelcontextprotocol/go-sdk|use\s+rmcp\b|mcp::server|mcp_server\.h", code):
269 return "mcp"
270
271 # Check if it has any LLM patterns
272 if StaticAnalyzer.detect_workflow(code):
273 return "generic-llm"
274
275 return None
276
277static_analyzer = StaticAnalyzer()

Callers

nothing calls this directly

Calls 1

detect_workflowMethod · 0.80

Tested by

no test coverage detected