test_full_integration.pyā¢2.48 kB
#!/usr/bin/env python3
"""
Full integration test for Finizi B4B MCP Server.
Tests the complete flow: connect -> list tools -> login -> call authenticated tool
"""
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def test_full_integration():
print("š Starting full integration test...\n")
# Server parameters matching Claude Desktop config
server_params = StdioServerParameters(
command="/Users/trunghuynh/.local/bin/uv",
args=[
"--directory",
"/Users/trunghuynh/development/finizi-mcp",
"run",
"python",
"run_mcp_server.py"
],
env={
"B4B_API_BASE_URL": "http://localhost:8000",
"B4B_API_VERSION": "v1",
"LOG_LEVEL": "INFO"
}
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# Initialize session
await session.initialize()
print("ā
Session initialized!\n")
# List tools
tools = await session.list_tools()
print(f"ā
Found {len(tools.tools)} tools:\n")
for i, tool in enumerate(tools.tools, 1):
print(f"{i:2d}. {tool.name}")
print()
# Test login
print("š Testing login...")
login_result = await session.call_tool(
"login",
arguments={
"phone": "+84909495665",
"password": "Admin123@"
}
)
print(f"ā
Login result: {login_result.content[0].text}\n")
# Test whoami (requires authentication)
print("š Testing whoami (authenticated call)...")
whoami_result = await session.call_tool("whoami", arguments={})
print(f"ā
Whoami result: {whoami_result.content[0].text}\n")
# Test list_entities (requires authentication)
print("š Testing list_entities (authenticated call)...")
entities_result = await session.call_tool(
"list_entities",
arguments={"page": 1, "page_size": 5}
)
print(f"ā
Entities result: {entities_result.content[0].text[:200]}...\n")
print("ā
All integration tests passed!")
if __name__ == "__main__":
asyncio.run(test_full_integration())