Skip to main content
Glama
moma1992

Yaizu Smart City MCP Server

by moma1992

search_api_docs

Search Yaizu City's API documentation by keyword to find specific APIs for accessing municipal data, facilities, disaster information, and tourism services.

Instructions

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

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

Returns: str: 検索結果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes

Implementation Reference

  • The primary handler function for the 'search_api_docs' tool. Decorated with @mcp.tool() for automatic registration and schema inference from signature/docstring. Calls doc_manager.search_apis() and formats markdown output.
    @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 helper method in APIDocumentManager class that implements the keyword search logic across all loaded API documentation files, matching against API name, description, and category.
    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, handling schema generation from the function signature and docstring.
    @mcp.tool()

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