Skip to content

Commit 3d4bdb2

Browse files
committed
Merge branch 'main' into feature
2 parents 658e3ed + 75bb4d3 commit 3d4bdb2

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

src/mcp_server_obp/server.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,43 @@
5757
# NEW HYBRID TAG-BASED ENDPOINT TOOLS (RECOMMENDED)
5858
# ============================================================================
5959

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+
6097
@mcp.tool()
6198
def list_endpoints_by_tag(tags: List[str]) -> str:
6299
"""
@@ -149,10 +186,10 @@ def get_endpoint_schema(endpoint_id: str) -> str:
149186
async def call_obp_api(
150187
ctx: Context,
151188
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 = {}
156193
) -> str:
157194
"""
158195
Execute an OBP API request to a specific endpoint.

0 commit comments

Comments
 (0)