Skip to main content
Glama

Schwab Model Context Protocol Server

by jkoelker
quotes.py1.72 kB
# from typing import Annotated from mcp.server.fastmcp import FastMCP from schwab_mcp.context import SchwabContext, SchwabServerContext from schwab_mcp.tools._registration import register_tool from schwab_mcp.tools.utils import JSONType, call async def get_quotes( ctx: SchwabContext, symbols: Annotated[ list[str] | str, "List of symbols or comma-separated string (e.g., ['AAPL', 'MSFT'] or 'GOOG,AMZN')", ], fields: Annotated[ list[str] | str | None, "Data fields (list/str): QUOTE, FUNDAMENTAL, EXTENDED, REFERENCE, REGULAR. Default is QUOTE.", ] = None, indicative: Annotated[ bool | None, "True for indicative quotes (extended hours/futures)" ] = None, ) -> JSONType: """ Returns current market quotes for specified symbols (stocks, ETFs, indices, options). Params: symbols (list or comma-separated string), fields (list/str: QUOTE/FUNDAMENTAL/etc.), indicative (bool). """ context: SchwabServerContext = ctx.request_context.lifespan_context client = context.quotes if isinstance(symbols, str): symbols = [s.strip() for s in symbols.split(",")] field_enums = None if fields: if isinstance(fields, str): fields = [f.strip() for f in fields.split(",")] field_enums = [client.Quote.Fields[f.upper()] for f in fields] return await call( client.get_quotes, symbols, fields=field_enums, indicative=indicative if indicative is not None else None, ) _READ_ONLY_TOOLS = (get_quotes,) def register(server: FastMCP, *, allow_write: bool) -> None: _ = allow_write for func in _READ_ONLY_TOOLS: register_tool(server, func)

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/jkoelker/schwab-mcp'

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