forked from inmydata/AgentMCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-client.py
More file actions
47 lines (37 loc) · 1.56 KB
/
Copy pathtest-client.py
File metadata and controls
47 lines (37 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
from dotenv import load_dotenv
import asyncio
from fastmcp.client import Client
from fastmcp.client.transports import StreamableHttpTransport
load_dotenv(".env", override=True)
# With custom headers for authentication
transport = StreamableHttpTransport(
url="http://localhost:8000/mcp",
headers={
"x-inmydata-api-key": os.environ.get('INMYDATA_API_KEY', ""),
"x-inmydata-tenant": os.environ.get('INMYDATA_TENANT', ""),
"x-inmydata-server": os.environ.get('INMYDATA_SERVER',"inmydata.com"),
"x-inmydata-calendar": os.environ.get('INMYDATA_CALENDAR',"default"),
"x-inmydata-user": os.environ.get('INMYDATA_USER', 'mcp-agent'),
"x-inmydata-session-id": os.environ.get('INMYDATA_SESSION_ID', 'mcp-session'),
"x-inmydata-session-id": os.environ.get('INMYDATA_TYPE', "")
}
)
client = Client(transport)
async def main():
async with client:
# Basic server interaction
await client.ping()
# List available operations
tools = await client.list_tools()
resources = await client.list_resources()
prompts = await client.list_prompts()
#print("Available tools:", tools)
# Execute operations
result = await client.call_tool("get_schema", {})
print(result)
result = await client.call_tool("get_financial_periods", {})
print(result)
result = await client.call_tool("get_calendar_period_date_range", {"financial_year":2023, "period_number":3, "period_type":"month"})
print(result)
asyncio.run(main())