|
57 | 57 | # NEW HYBRID TAG-BASED ENDPOINT TOOLS (RECOMMENDED) |
58 | 58 | # ============================================================================ |
59 | 59 |
|
| 60 | +@mcp.tool() |
| 61 | +def list_all_endpoint_tags() -> str: |
| 62 | + """ |
| 63 | + Get all available OBP API endpoint tags. |
| 64 | + |
| 65 | + Use this to discover what tags are available before calling list_endpoints_by_tag(). |
| 66 | + Tags represent different categories of endpoints (e.g., "Account", "Transaction", "Customer"). |
| 67 | + |
| 68 | + Returns: |
| 69 | + JSON string with all available tags and their endpoint counts |
| 70 | + |
| 71 | + Example: |
| 72 | + list_all_endpoint_tags() -> Returns all available tags with counts |
| 73 | + """ |
| 74 | + try: |
| 75 | + index = get_endpoint_index() |
| 76 | + tags = index.get_all_tags() |
| 77 | + |
| 78 | + # Count endpoints per tag |
| 79 | + tag_counts = {} |
| 80 | + for tag in tags: |
| 81 | + endpoints = index.list_endpoints_by_tag([tag]) |
| 82 | + tag_counts[tag] = len(endpoints) |
| 83 | + |
| 84 | + # Sort by count descending |
| 85 | + sorted_tags = sorted(tag_counts.items(), key=lambda x: x[1], reverse=True) |
| 86 | + |
| 87 | + return json.dumps({ |
| 88 | + "total_tags": len(tags), |
| 89 | + "tags": [{"tag": tag, "endpoint_count": count} for tag, count in sorted_tags] |
| 90 | + }, indent=2) |
| 91 | + |
| 92 | + except Exception as e: |
| 93 | + logger.error(f"Error listing endpoint tags: {e}") |
| 94 | + return json.dumps({"error": str(e)}, indent=2) |
| 95 | + |
| 96 | + |
60 | 97 | @mcp.tool() |
61 | 98 | def list_endpoints_by_tag(tags: List[str]) -> str: |
62 | 99 | """ |
@@ -149,10 +186,10 @@ def get_endpoint_schema(endpoint_id: str) -> str: |
149 | 186 | async def call_obp_api( |
150 | 187 | ctx: Context, |
151 | 188 | endpoint_id: str, |
152 | | - path_params: dict = None, |
153 | | - query_params: dict = None, |
154 | | - body: dict = None, |
155 | | - headers: dict = None, |
| 189 | + path_params: dict = {}, |
| 190 | + query_params: dict = {}, |
| 191 | + body: dict = {}, |
| 192 | + headers: dict = {} |
156 | 193 | ) -> str: |
157 | 194 | """ |
158 | 195 | Execute an OBP API request to a specific endpoint. |
|
0 commit comments