Accessing the LRA MCP server with a Refresh or Access Token
For temporary experiments or batch jobs, you can access the LRA MCP server with either a refresh token or an access token. You can fetch the tokens from https://kfinance.kensho.com/manual_login/ (opens in a new tab). The access token expires after one hour while the refresh token expires after one week.
Getting started with just an access token is easiest for tasks or experiments that take less than an hour. You can use the script below as a starting point.
Click to expand code
Python
import asyncio
from fastmcp import Client as FastMcpClient
# Fetch an access token from https://kfinance.kensho.com/manual_login/
ACCESS_TOKEN = "<your-access-token>"
fastmcp_client = FastMcpClient(
transport="https://kfinance.kensho.com/integrations/mcp",
auth=ACCESS_TOKEN,
)
async def list_tools():
"""Fetch a list of all available tools."""
async with fastmcp_client:
tools = await fastmcp_client.list_tools()
print(f"\nSuccessfully fetched a list of {len(tools)} tools, starting with {tools[0].name}.")
async def fetch_msft_2024_revenue():
"""Fetch Microsoft's 2024 revenue.
Usually, you won't have to generate all of the arguments yourself.
Instead, an LLM will generate them for you, based on the tool information
that it receives as part of the list_tools call.
"""
async with fastmcp_client:
result = await fastmcp_client.call_tool(
"get_financial_line_item_from_identifiers",
arguments={
"identifiers": ["MSFT"],
"line_item": "revenue",
"start_year": 2024,
"end_year": 2024,
},
)
print(f"\n Microsoft's 2024 revenue is {result.data}")
asyncio.run(list_tools())
asyncio.run(fetch_msft_2024_revenue())