Skip to content

Commit 75bb4d3

Browse files
committed
feature/add list_all_endpoint_tags endpoint
1 parent 8dbdd61 commit 75bb4d3

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/mcp_server_obp/server.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,43 @@
5353
# NEW HYBRID TAG-BASED ENDPOINT TOOLS (RECOMMENDED)
5454
# ============================================================================
5555

56+
@mcp.tool()
57+
def list_all_endpoint_tags() -> str:
58+
"""
59+
Get all available OBP API endpoint tags.
60+
61+
Use this to discover what tags are available before calling list_endpoints_by_tag().
62+
Tags represent different categories of endpoints (e.g., "Account", "Transaction", "Customer").
63+
64+
Returns:
65+
JSON string with all available tags and their endpoint counts
66+
67+
Example:
68+
list_all_endpoint_tags() -> Returns all available tags with counts
69+
"""
70+
try:
71+
index = get_endpoint_index()
72+
tags = index.get_all_tags()
73+
74+
# Count endpoints per tag
75+
tag_counts = {}
76+
for tag in tags:
77+
endpoints = index.list_endpoints_by_tag([tag])
78+
tag_counts[tag] = len(endpoints)
79+
80+
# Sort by count descending
81+
sorted_tags = sorted(tag_counts.items(), key=lambda x: x[1], reverse=True)
82+
83+
return json.dumps({
84+
"total_tags": len(tags),
85+
"tags": [{"tag": tag, "endpoint_count": count} for tag, count in sorted_tags]
86+
}, indent=2)
87+
88+
except Exception as e:
89+
logger.error(f"Error listing endpoint tags: {e}")
90+
return json.dumps({"error": str(e)}, indent=2)
91+
92+
5693
@mcp.tool()
5794
def list_endpoints_by_tag(tags: List[str]) -> str:
5895
"""

0 commit comments

Comments
 (0)