Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

watch_get

Retrieve real-time data for a specific stock by entering its code and market to monitor individual positions in A-shares, Hong Kong, or US markets.

Instructions

获取单个观察股票

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes股票代码
marketYes市场

Implementation Reference

  • The getWatch function implementation that loads the watch list and finds a single watch item by code and market
    // 获取单个观察股票
    export function getWatch(code: string, market: Market): WatchItem | null {
      const watchList = loadWatchList();
      return watchList.find(item => item.code === code && item.market === market) || null;
    }
  • src/index.ts:252-263 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining watch_get with name, description, and inputSchema
    {
      name: 'watch_get',
      description: '获取单个观察股票',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: '股票代码' },
          market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' },
        },
        required: ['code', 'market'],
      },
    },
  • The MCP tool request handler for watch_get that parses arguments, calls watch.getWatch(), and returns the result
    if (name === 'watch_get') {
      const params = GetWatchSchema.parse(args);
      const result = watch.getWatch(params.code, params.market as Market);
      if (!result) {
        throw new Error('Watch item not found');
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Zod schema for validating watch_get input parameters (code and market)
    const GetWatchSchema = z.object({
      code: z.string().describe('股票代码'),
      market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'),
    });
  • WatchItem interface defining the structure of watch list items returned by watch_get
    // 观察股票信息
    export interface WatchItem {
      code: string;
      name: string;
      reason: string;
      market: Market;
      createdAt: string;
    }

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/kinmeic/stock-mcp'

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