Skip to main content
Glama
financial-datasets

Financial Datasets MCP Server

Official

get_current_stock_price

Retrieve the current stock price for a company by providing its ticker symbol using the Financial Datasets MCP Server.

Instructions

Get the current / latest price of a company.

Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • The main handler function for the 'get_current_stock_price' tool. It is registered via the @mcp.tool() decorator and implements the core logic by making an API request to retrieve the latest stock price snapshot for the given ticker symbol and returns it as a formatted JSON string.
    @mcp.tool() async def get_current_stock_price(ticker: str) -> str: """Get the current / latest price of a company. Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL) """ # Fetch data from the API url = f"{FINANCIAL_DATASETS_API_BASE}/prices/snapshot/?ticker={ticker}" data = await make_request(url) # Check if data is found if not data: return "Unable to fetch current price or no current price found." # Extract the current price snapshot = data.get("snapshot", {}) # Check if current price is found if not snapshot: return "Unable to fetch current price or no current price found." # Stringify the current price return json.dumps(snapshot, indent=2)
  • Helper utility function used by the get_current_stock_price tool (and others) to perform authenticated HTTP GET requests to the Financial Datasets API, handling dotenv loading, headers, timeouts, and errors.
    async def make_request(url: str) -> dict[str, any] | None: """Make a request to the Financial Datasets API with proper error handling.""" # Load environment variables from .env file load_dotenv() headers = {} if api_key := os.environ.get("FINANCIAL_DATASETS_API_KEY"): headers["X-API-KEY"] = api_key async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except Exception as e: return {"Error": str(e)}
  • server.py:139-139 (registration)
    The @mcp.tool() decorator registers the get_current_stock_price function as an MCP tool with the FastMCP server.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/financial-datasets/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server