Skip to main content
Glama
kinmeic

Stock MCP Server

by kinmeic

position_get

Retrieve a specific stock position record by providing the stock code and market identifier. Use this tool to access individual holding details for portfolio management.

Instructions

获取单个持仓记录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes股票代码
marketYes市场

Implementation Reference

  • Main handler for position_get tool that parses arguments, calls position.getPosition(), and returns the result
    if (name === 'position_get') { const params = GetPositionSchema.parse(args); const result = position.getPosition(params.code, params.market as Market); if (!result) { throw new Error('Position not found'); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Implementation of getPosition function that loads positions from file and finds a single position by code and market
    // 获取单个持仓 export function getPosition(code: string, market: Market): Position | null { const positions = loadPositions(); return positions.find(p => p.code === code && p.market === market) || null; }
  • src/index.ts:192-203 (registration)
    Tool registration for position_get in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema
    { name: 'position_get', description: '获取单个持仓记录', inputSchema: { type: 'object', properties: { code: { type: 'string', description: '股票代码' }, market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' }, }, required: ['code', 'market'], }, },
  • Zod validation schema for position_get tool parameters (code and market)
    const GetPositionSchema = z.object({ code: z.string().describe('股票代码'), market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'), });
  • Type definition for Position interface that defines the structure of position data returned by position_get
    export interface Position { code: string; name: string; quantity: number; costPrice: number; currency: string; market: Market; createdAt: string; updatedAt: 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