tech-wizard-mcp / tools.py
Brettapps's picture
Upload folder using huggingface_hub
fe893f9 verified
from tech_wizard.tech_kb import TechKnowledgeBase
from tech_wizard.openai_module import OpenAIClient
import os
import json
class TechWizardTools:
def __init__(self, openai_api_key=None):
self.kb = TechKnowledgeBase()
self.llm = OpenAIClient(api_key=openai_api_key or os.getenv("OPENAI_API_KEY"))
def architect_system(self, requirements: str) -> str:
"""Design a technical system architecture."""
kb_context = self.kb.get_info("architecture")
prompt = f"""
Requirements: {requirements}
Architecture Patterns Knowledge: {json.dumps(kb_context, indent=2)}
Please design a technical architecture. Include:
1. Recommended Pattern (e.g., Microservices vs Monolith).
2. Technology Stack (Frontend, Backend, DB, Cache).
3. A Mermaid.js diagram representing the system.
4. Scalability and Security considerations.
"""
return self.llm.chat(prompt)
def design_api(self, features: str) -> str:
"""Design a secure and versioned API surface."""
kb_context = self.kb.get_info("api")
prompt = f"""
Feature Requirements: {features}
API Best Practices: {json.dumps(kb_context, indent=2)}
Design a REST or GraphQL API surface. Include:
1. Endpoint paths and methods.
2. Request/Response schemas (JSON).
3. Authentication/Authorization strategy.
4. Error handling logic.
"""
return self.llm.chat(prompt)
def setup_webhooks(self, source_platform: str) -> str:
"""Generate secure webhook handler logic."""
kb_context = self.kb.get_info("webhooks")
prompt = f"""
Source Platform (e.g., Stripe, GitHub, Shopify): {source_platform}
Webhook Knowledge: {json.dumps(kb_context, indent=2)}
Generate a secure webhook handler (Python/FastAPI or Node.js).
Must include signature verification, idempotency, and asynchronous processing.
"""
return self.llm.chat(prompt)
def configure_routing(self, domain: str, app_details: str) -> str:
"""Design DNS and routing configuration."""
kb_context = self.kb.get_info("domains")
prompt = f"""
Domain: {domain}
App/Infrastructure Details: {app_details}
Routing Knowledge: {json.dumps(kb_context, indent=2)}
Provide a DNS configuration plan (A, CNAME, TXT records) and SSL/TLS strategy.
"""
return self.llm.chat(prompt)