Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

position_remove

Remove a stock position from your portfolio by specifying the stock code and market, helping you manage your investment holdings.

Instructions

删除持仓记录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes股票代码
marketYes市场

Implementation Reference

  • The handler function that processes position_remove tool calls. It validates input using RemovePositionSchema, calls position.removePosition(), and returns a success/error response.
    if (name === 'position_remove') {
      const params = RemovePositionSchema.parse(args);
      const success = position.removePosition(params.code, params.market as Market);
      if (!success) {
        throw new Error('Position not found');
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({ success: true }, null, 2),
          },
        ],
      };
    }
  • Core implementation of removePosition function. Loads positions from JSON file, finds the position by code and market, removes it using splice(), saves changes, and returns success status.
    export function removePosition(code: string, market: Market): boolean {
      const positions = loadPositions();
      const index = positions.findIndex(p => p.code === code && p.market === market);
    
      if (index === -1) {
        return false;
      }
    
      positions.splice(index, 1);
      savePositions(positions);
      return true;
    }
  • Zod schema definition for position_remove tool input validation, requiring 'code' (string) and 'market' (enum: sh/sz/hk/us) parameters.
    const RemovePositionSchema = z.object({
      code: z.string().describe('股票代码'),
      market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'),
    });
  • src/index.ts:172-183 (registration)
    Tool registration in ListToolsRequestSchema handler that exposes position_remove to MCP clients with description and input schema.
    {
      name: 'position_remove',
      description: '删除持仓记录',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: '股票代码' },
          market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' },
        },
        required: ['code', 'market'],
      },
    },
  • Helper functions loadPositions() and savePositions() used by removePosition to read/write position data from positions.json file.
    function loadPositions(): Position[] {
      try {
        if (fs.existsSync(DATA_FILE)) {
          const data = fs.readFileSync(DATA_FILE, 'utf-8');
          return JSON.parse(data);
        }
      } catch (error) {
        console.error('Failed to load positions:', error);
      }
      return [];
    }
    
    // 保存持仓数据
    function savePositions(positions: Position[]): void {
      fs.writeFileSync(DATA_FILE, JSON.stringify(positions, null, 2));
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states 'delete' which implies a destructive mutation, but doesn't specify if this requires authentication, what happens on success/failure, whether deletions are permanent, or any rate limits. 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, efficient phrase ('删除持仓记录') that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded for this simple tool.

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?

For a destructive mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what constitutes a 'position record', what gets returned (if anything), error handling, or security implications. Given the complexity and lack of structured data, more context is needed.

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 already documents both parameters ('code' and 'market') with descriptions and enum values. The description doesn't add any parameter meaning beyond what the schema provides, meeting the baseline for high coverage.

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 '删除持仓记录' (delete position record) clearly states the action (delete) and resource (position record), but it doesn't differentiate from sibling tools like 'watch_remove' or specify what distinguishes a 'position' record from other types. It's a straightforward purpose statement without sibling context.

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 'position_update' or 'watch_remove'. The description doesn't mention prerequisites, error conditions, or contextual constraints, leaving usage entirely implicit.

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