Skip to content

Instantly share code, notes, and snippets.

@rajeshsingh520
Created February 25, 2026 07:08
Show Gist options
  • Select an option

  • Save rajeshsingh520/7f5a655a06fc1cefba898df1a3197c43 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/7f5a655a06fc1cefba898df1a3197c43 to your computer and use it in GitHub Desktop.
to see the available tools in woocommerce mcp server in python
import json
import httpx
URL = "https://landing.local/wp-json/woocommerce/mcp"
CK = "ck_a9bf627784b1d8d51c21ce6f52a0fd60f20b579e"
CS = "cs_0367a201dcea028c090dde0b88e619cf7df86329"
base_headers = {
"Content-Type": "application/json",
"X-MCP-API-Key": f"{CK}:{CS}"
}
with httpx.Client(verify=False) as client:
# 1️⃣ Initialize
init_response = client.post(
URL,
headers=base_headers,
json={
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"clientInfo": {
"name": "python-debug",
"version": "1.0"
}
}
}
)
if init_response.status_code != 200:
print("Initialize failed:")
print(init_response.text)
exit()
session_id = init_response.headers.get("Mcp-Session-Id")
if not session_id:
print("No Mcp-Session-Id returned.")
print(init_response.text)
exit()
# 2️⃣ Tools List
tools_response = client.post(
URL,
headers={
**base_headers,
"Mcp-Session-Id": session_id
},
json={
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}
)
if tools_response.status_code != 200:
print("Tools list failed:")
print(tools_response.text)
exit()
tools_data = tools_response.json()
# Print only tool names
print("\n=== TOOL NAMES ===")
for tool in tools_data.get("result", {}).get("tools", []):
print("-", tool.get("name"))
# Save full output
with open("mcp_tools.json", "w", encoding="utf-8") as f:
json.dump(tools_data, f, indent=2)
print("\nFull tool schema saved to mcp_tools.json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment