/**
* MCP Tool: get_current_price
*
* Fetch up-to-date price for a given symbol.
*/
import { z } from "zod";
import { getDefaultProvider } from "../marketData";
export const getCurrentPriceSchema = z.object({
symbol: z.string().describe("Stock/ETF ticker symbol (e.g., AAPL, SPY)"),
});
export type GetCurrentPriceInput = z.infer<typeof getCurrentPriceSchema>;
export interface GetCurrentPriceOutput {
symbol: string;
price: number;
timestamp: string;
}
export async function getCurrentPrice(
input: GetCurrentPriceInput
): Promise<GetCurrentPriceOutput> {
const provider = getDefaultProvider();
const quote = await provider.getQuote(input.symbol);
return {
symbol: quote.symbol,
price: quote.price,
timestamp: new Date(quote.timestamp).toISOString(),
};
}
export const getCurrentPriceDefinition = {
name: "get_current_price",
description:
"Fetch up-to-date price for a given stock/ETF symbol. Use this to get the current spot price before running any pricing or simulation tools.",
inputSchema: {
type: "object",
properties: {
symbol: {
type: "string",
description: "Stock/ETF ticker symbol (e.g., AAPL, SPY, NVDA)",
},
},
required: ["symbol"],
},
};