Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

watch_add

Add stocks to your watchlist by specifying code, name, market, and reason for tracking. Monitor A-shares, Hong Kong, and US stocks for informed investment decisions.

Instructions

添加观察股票

Input Schema

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

Implementation Reference

  • The core implementation of addWatch function that adds a stock to the watch list. It loads existing data, checks for duplicates, creates a new WatchItem with timestamp, saves to watch.json file, and returns the new item.
    export function addWatch(
      code: string,
      name: string,
      reason: string,
      market: Market
    ): WatchItem {
      const watchList = loadWatchList();
    
      // 检查是否已存在
      const exists = watchList.some(item => item.code === code && item.market === market);
      if (exists) {
        throw new Error('Stock already in watch list');
      }
    
      const newItem: WatchItem = {
        code,
        name,
        reason,
        market,
        createdAt: new Date().toISOString(),
      };
    
      watchList.push(newItem);
      saveWatchList(watchList);
    
      return newItem;
    }
  • The MCP tool handler for watch_add that parses input arguments using AddWatchSchema, calls watch.addWatch() function with the parameters, and returns the result as formatted JSON.
    if (name === 'watch_add') {
      const params = AddWatchSchema.parse(args);
      const result = watch.addWatch(
        params.code,
        params.name,
        params.reason,
        params.market as Market
      );
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • src/index.ts:204-217 (registration)
    Tool registration for watch_add defining its name, description, input schema properties (code, name, reason, market), and required fields.
    {
      name: 'watch_add',
      description: '添加观察股票',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: '股票代码' },
          name: { type: 'string', description: '股票名称' },
          reason: { type: 'string', description: '观察理由或目标' },
          market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' },
        },
        required: ['code', 'name', 'reason', 'market'],
      },
    },
  • Zod schema definition (AddWatchSchema) for input validation with required fields: code (string), name (string), reason (string), and market (enum: sh, sz, hk, us).
    const AddWatchSchema = z.object({
      code: z.string().describe('股票代码'),
      name: z.string().describe('股票名称'),
      reason: z.string().describe('观察理由或目标'),
      market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'),
    });
  • Type definition for WatchItem interface defining the structure of watch list items with code, name, reason, market, and createdAt fields.
    export interface WatchItem {
      code: string;
      name: string;
      reason: string;
      market: Market;
      createdAt: string;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this is a mutation requiring permissions, whether it's idempotent, what happens on duplicate entries, or any rate limits. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient phrase '添加观察股票' that is front-loaded and wastes no words. It's appropriately sized for a simple tool, though its brevity contributes to gaps in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a mutation tool with 4 required parameters. It doesn't explain what the tool returns, error conditions, or how it interacts with sibling tools like 'watch_list', leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents parameters like 'code' for stock code and 'market' with enum values. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or constraints, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '添加观察股票' (Add watch stock) states the action (add) and resource (watch stock), but it's vague about what 'watch' entails compared to siblings like 'position_add' or 'stock_get'. It doesn't specify if this creates a monitoring entry, alert list, or portfolio tracking, leaving ambiguity in purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'watch_update' or 'position_add'. The description lacks context about prerequisites, such as whether the stock must exist in the system, or exclusions, making it unclear how it fits into the workflow with sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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