import mcp
import json
# Configure your Corvic MCP endpoint and token
MCP_ENDPOINT = "<<MCP_ENDPOINT>>"
CORVIC_API_TOKEN = "<<YOUR_CORVIC_API_TOKEN>>"
# Create SSE client connection
headers = {
"Authorization": f"Bearer {CORVIC_API_TOKEN}",
"Content-Type": "application/json"
}
# Initialize MCP client
async with mcp.ClientSession(
transport=mcp.SSEClientTransport(MCP_ENDPOINT, headers=headers)
) as session:
# Initialize the session
init_result = await session.initialize()
# List available tools
tools = await session.list_tools()
print(f"Available tools: {[tool.name for tool in tools.tools]}")
# Call the query tool
query_result = await session.call_tool(
"query",
arguments={
"query_content": "Map the NAICS code 441228 from 2017 to the 2022 NAICS code."
}
)
# Extract and save response
response_text = query_result.content[0].text if query_result.content else ""
# Save to markdown file
with open("naics_mapping_result.md", "w") as f:
f.write(response_text)
print("Response saved to naics_mapping_result.md")