Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

watch_update

Update stock watchlist entries by modifying codes, markets, names, or reasons for tracking specific securities in real-time market monitoring.

Instructions

更新观察股票(名称或观察理由)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes股票代码
marketYes市场
nameNo股票名称
reasonNo观察理由或目标

Implementation Reference

  • Handler function for watch_update tool that parses arguments and calls watch.updateWatch implementation
    if (name === 'watch_update') {
      const params = UpdateWatchSchema.parse(args);
      const result = watch.updateWatch(
        params.code,
        params.market as Market,
        {
          name: params.name,
          reason: params.reason,
        }
      );
      if (!result) {
        throw new Error('Watch item not found');
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core implementation of updateWatch function that loads watch list, finds and updates the specified stock item, then saves the list
    export function updateWatch(
      code: string,
      market: Market,
      updates: Partial<Pick<WatchItem, 'name' | 'reason'>>
    ): WatchItem | null {
      const watchList = loadWatchList();
      const index = watchList.findIndex(item => item.code === code && item.market === market);
    
      if (index === -1) {
        return null;
      }
    
      watchList[index] = {
        ...watchList[index],
        ...updates,
      };
    
      saveWatchList(watchList);
      return watchList[index];
    }
  • Zod schema definition for UpdateWatchSchema that validates watch_update tool parameters
    const UpdateWatchSchema = z.object({
      code: z.string().describe('股票代码'),
      market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'),
      name: z.string().optional().describe('股票名称'),
      reason: z.string().optional().describe('观察理由或目标'),
    });
  • src/index.ts:218-231 (registration)
    Tool registration for watch_update in the ListTools handler with description and input schema
    {
      name: 'watch_update',
      description: '更新观察股票(名称或观察理由)',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: '股票代码' },
          market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' },
          name: { type: 'string', description: '股票名称' },
          reason: { type: 'string', description: '观察理由或目标' },
        },
        required: ['code', 'market'],
      },
    },
  • Type definition for WatchItem interface used by watch_update operations
    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