Skip to main content
Glama
mkotsollaris

kwrds.ai MCP Server

by mkotsollaris
ai_handlers.py1.9 kB
""" AI Handlers Handles AI-powered keyword research and content generation MCP tool calls """ from typing import Dict, Any from utils.http_client import make_api_request from utils.response_utils import limit_response_size, truncate_string_fields class AIHandlers: def __init__(self, api_base_url: str): self.api_base_url = api_base_url def handle_ai(self, args: Dict[str, Any], api_key: str) -> Dict[str, Any]: """Handle AI tool call""" url = f"{self.api_base_url}/ai" headers = {"X-API-KEY": api_key, "Content-Type": "application/json"} data = { "search_question": args["search_question"], "search_country": args["search_country"], "prompt": args["prompt"], "email": api_key # Using API key as email for compatibility } response = make_api_request(url, headers, data) limited_response = limit_response_size(response, max_items=10) return truncate_string_fields(limited_response, max_length=1000) def handle_ai_content(self, args: Dict[str, Any], api_key: str) -> Dict[str, Any]: """Handle AI content generation tool call""" url = f"{self.api_base_url}/ai/content" headers = {"X-API-KEY": api_key, "Content-Type": "application/json"} data = { "search_question": args["search_question"], "search_country": args["search_country"], "prompt": args["prompt"], "email": api_key # Using API key as email for compatibility } if "title" in args: data["title"] = args["title"] if "description" in args: data["description"] = args["description"] response = make_api_request(url, headers, data) limited_response = limit_response_size(response, max_items=10) return truncate_string_fields(limited_response, max_length=1000)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mkotsollaris/kwrds_ai_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server