Skip to main content
Glama
moma1992

Yaizu Smart City MCP Server

by moma1992

search_api_docs

Search saved API documentation by keyword to find relevant APIs for Yaizu City's smart city services and open data access.

Instructions

保存済みのAPIドキュメントから特定のキーワードでAPIを検索します。

Args: keyword: 検索キーワード(API名、説明、カテゴリで検索)

Returns: str: 検索結果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes

Implementation Reference

  • Main handler function for the 'search_api_docs' tool, decorated with @mcp.tool() for automatic registration and schema inference. It delegates search to doc_manager.search_apis and formats the results as markdown.
    @mcp.tool() async def search_api_docs(keyword: str) -> str: """ 保存済みのAPIドキュメントから特定のキーワードでAPIを検索します。 Args: keyword: 検索キーワード(API名、説明、カテゴリで検索) Returns: str: 検索結果 """ try: results = doc_manager.search_apis(keyword) if not results: return f"「{keyword}」に一致するAPIが見つかりませんでした。" output = f"# 検索結果: 「{keyword}」\n\n" output += f"**{len(results)}件** のAPIが見つかりました:\n\n" for i, result in enumerate(results, 1): api = result['api'] output += f"## {i}. {api.get('name', '名称不明')}\n" output += f"- **説明**: {api.get('description', '説明なし')}\n" output += f"- **カテゴリ**: {api.get('category', '未分類')}\n" output += f"- **防災関連**: {'はい' if api.get('is_disaster_related') else 'いいえ'}\n" output += f"- **ソースファイル**: {result['source_file']}.json\n" if api.get('endpoints'): output += f"- **エンドポイント**: {', '.join(api['endpoints'][:3])}\n" output += "\n" return output except Exception as e: logger.error(f"検索エラー: {e}") return f"❌ 検索中にエラーが発生しました: {str(e)}"
  • Core search logic in APIDocumentManager class. Scans all available API JSON files, searches within 'apis' arrays for matching keyword in name, description, or category, and returns list of matches with source file info.
    def search_apis(self, keyword: str) -> List[Dict[str, Any]]: """キーワードでAPIを検索""" results = [] # すべてのドキュメントを検索 for doc_file in self.list_available_docs(): doc = self.load_api_docs(doc_file) if not doc: continue # APIs配列がある場合 if 'apis' in doc: for api in doc['apis']: # 名前と説明で検索 if (keyword.lower() in api.get('name', '').lower() or keyword.lower() in api.get('description', '').lower() or keyword.lower() in api.get('category', '').lower()): results.append({ 'source_file': doc_file, 'api': api }) return results
  • mcp/server.py:273-273 (registration)
    The @mcp.tool() decorator registers the search_api_docs function as an MCP tool, with schema automatically derived from type annotations and docstring.
    @mcp.tool()
  • Type hints (keyword: str -> str) and docstring provide the input/output schema for the tool.
    async def search_api_docs(keyword: str) -> str: """ 保存済みのAPIドキュメントから特定のキーワードでAPIを検索します。 Args: keyword: 検索キーワード(API名、説明、カテゴリで検索) Returns: str: 検索結果 """

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/moma1992/smartcity-mcp'

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