
Diabetic Foot Care Products & Footwear: Daily Prevention & Offloading Guidelines
Created At: 2026-07-29T12:59:36+05:30
Completed At: 2026-07-29T12:59:36+05:30
File Path: `file:///d:/workspace/blogs-agent-harness/mcp_client.py`
Total Lines: 115
Total Bytes: 11345
Showing lines 1 to 115
The following code has been modified to include a line number before every line, in the format:
1: import sys, json, subprocess, os
2:
3: def call_mcp(command, tool_name, args, env=None):
4: merged_env = os.environ.copy()
5: if env:
6: merged_env.update(env)
7:
8: p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True, env=merged_env)
9:
10: # send initialize
11: init_req = {
12: “jsonrpc”: “2.0”,
13: “id”: 1,
14: “method”: “initialize”,
15: “params”: {
16: “protocolVersion”: “2024-11-05”,
17: “capabilities”: {},
18: “clientInfo”: {“name”: “test”, “version”: “1.0”}
19: }
20: }
21: p.stdin.write(json.dumps(init_req) + “\n”)
22: p.stdin.flush()
23:
24: # read init response
25: for line in p.stdout:
26: try:
27: resp = json.loads(line)
28: if resp.get(“id”) == 1:
29: break
30: except:
31: pass
32:
33: # send initialized
34: p.stdin.write(json.dumps({“jsonrpc”: “2.0”, “method”: “notifications/initialized”}) + “\n”)
35: p.stdin.flush()
36:
37: # send tool call
38: call_req = {
39: “jsonrpc”: “2.0”,
40: “id”: 2,
41: “method”: “tools/call”,
42: “params”: {
43: “name”: tool_name,
44: “arguments”: args
45: }
46: }
47: p.stdin.write(json.dumps(call_req) + “\n”)
48: p.stdin.flush()
49:
50: # read tool response
51: for line in p.stdout:
52: try:
53: resp =
90:
91: args = {
92: “title”: “Best Diabetologist in Thane | Top Sugar Doctor”,
93: “content”: content,
94: “status”: “draft”
95: }
96:
97: print(“Calling WordPress MCP…”)
98: call_mcp(wp_cmd, “wp_create_post”, args, wp_env)
99:
100: # Also for google sheets MCP:
101: gs_cmd = “npx -y @modelcontextprotocol/server-google-sheets”
102: gs_args = {
103: “spreadsheet_id”: “1CmgKQcyL8I4YTcV-HUvUbjU3W1b3bWw5hNmjReH9wjM”, # From .env
104: “range”: “Sheet1!A:G”, # Assuming Sheet1
105: “values”: [
106: [“2026-06-24T22:17:37+05:30”, “https://www.madhumeha.in”, “Best Sugar doctor in Thane”, “best diabetologist in thane”, “diabetes specialist in thane, top-rated diabetes clinic in thane, type 2 diabetes treatment in thane, sugar doctor near me”, “/best-diabetologist-in-thane”, “Published”]
107: ]
108: }
109: gs_env = {
110: “GOOGLE_APPLICATION_CREDENTIALS”: r”D:\workspace\blogs-agent-harness\credentials\ai-agents-harness-073b76f72108.json”
111: }
112:
113: print(“Calling Google Sheets MCP…”)
114: call_mcp(gs_cmd, “append_row”, gs_args, gs_env) # Let’s hope tool name is append_row
115:
The above content shows the entire, complete file contents of the requested file.
