Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

position_add

Add a new stock position to your portfolio by specifying code, quantity, cost price, currency, and market for tracking investments.

Instructions

添加持仓记录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes股票代码
nameYes股票名称
quantityYes持有数量
costPriceYes成本价
currencyYes货币单位,如 CNY、HKD、USD
marketYes市场

Implementation Reference

  • The core implementation of addPosition function that creates a new position record, loads existing positions from JSON file, creates a new Position object with timestamp, appends to the array, saves back to file, and returns the new position.
    export function addPosition(
      code: string,
      name: string,
      quantity: number,
      costPrice: number,
      currency: string,
      market: Market
    ): Position {
      const positions = loadPositions();
      const now = new Date().toISOString();
    
      const newPosition: Position = {
        code,
        name,
        quantity,
        costPrice,
        currency,
        market,
        createdAt: now,
        updatedAt: now,
      };
    
      positions.push(newPosition);
      savePositions(positions);
    
      return newPosition;
    }
  • src/index.ts:304-322 (registration)
    The request handler for position_add tool in CallToolRequestSchema that validates arguments using AddPositionSchema, calls position.addPosition with parsed parameters, and returns the result as JSON.
    if (name === 'position_add') {
      const params = AddPositionSchema.parse(args);
      const result = position.addPosition(
        params.code,
        params.name,
        params.quantity,
        params.costPrice,
        params.currency,
        params.market as Market
      );
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Zod validation schema AddPositionSchema that defines the expected input structure for position_add with fields: code, name, quantity, costPrice, currency, and market.
    const AddPositionSchema = z.object({
      code: z.string().describe('股票代码'),
      name: z.string().describe('股票名称'),
      quantity: z.number().positive().describe('持有数量'),
      costPrice: z.number().positive().describe('成本价'),
      currency: z.string().describe('货币单位,如 CNY、HKD、USD'),
      market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'),
    });
  • src/index.ts:142-157 (registration)
    Tool registration for position_add in ListToolsRequestSchema that exposes the tool to MCP clients with name, description, and input schema definition.
    {
      name: 'position_add',
      description: '添加持仓记录',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: '股票代码' },
          name: { type: 'string', description: '股票名称' },
          quantity: { type: 'number', description: '持有数量' },
          costPrice: { type: 'number', description: '成本价' },
          currency: { type: 'string', description: '货币单位,如 CNY、HKD、USD' },
          market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' },
        },
        required: ['code', 'name', 'quantity', 'costPrice', 'currency', 'market'],
      },
    },
  • The Position interface type definition that defines the structure of position objects including code, name, quantity, costPrice, currency, market, createdAt, and updatedAt fields.
    export interface Position {
      code: string;
      name: string;
      quantity: number;
      costPrice: number;
      currency: string;
      market: Market;
      createdAt: string;
      updatedAt: string;
    }
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description '添加持仓记录' implies a write operation (adding a record), but it doesn't disclose any behavioral traits: no information about permissions required, whether duplicates are allowed, what happens on success/failure, or any side effects (e.g., updating related data). This is inadequate for a mutation tool with zero annotation coverage.

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 Chinese phrase ('添加持仓记录') that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded, making it immediately clear what the tool does without unnecessary elaboration.

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 the complexity (a mutation tool with 6 required parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral context. While the schema covers parameters well, the description fails to provide necessary operational context for safe and effective 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?

The schema description coverage is 100%, with all 6 parameters clearly documented in the schema (e.g., code as stock code, market with enum values). The description adds no additional meaning about parameters beyond the schema. According to the rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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

Purpose4/5

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

The description '添加持仓记录' (add position record) clearly states the verb (add) and resource (position record), making the purpose immediately understandable. It distinguishes from siblings like position_get (retrieve), position_remove (delete), and position_update (modify) by focusing on creation. However, it doesn't specify what exactly constitutes a 'position record' beyond the parameters listed in the schema.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the stock must exist in the system), when not to use it (e.g., for updating existing positions), or direct alternatives like position_update for modifications. The agent must infer usage from the tool name and sibling context alone.

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