Skip to main content
Glama
zhenzp

Fund MCP Server

by zhenzp

fund.stock_search

Search for stock information using stock codes, names, or pinyin abbreviations to retrieve financial data from East Money API.

Instructions

搜索股票信息,基于东方财富API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes搜索关键字,如股票代码、股票名称或拼音简称
countNo返回结果数量,默认10,最大50

Implementation Reference

  • The core handler function that parses arguments with Zod schema, constructs URL for EastMoney stock suggest API, fetches data, and returns JSON stringified response.
    async function handleStockSearch(args: unknown) {
      const { input, count = 10 } = stockSearchSchema.parse(args);
    
      const url = new URL(STOCK_SEARCH_API_URL);
      url.searchParams.set("input", input);
      url.searchParams.set("type", "14");
      url.searchParams.set("status", "1");
      url.searchParams.set("count", String(count));
    
      const response = await fetch(url.toString(), {
        method: "GET",
        headers: {
          Accept: "application/json",
          "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
        },
      });
      console.log('response', response)
    
      if (!response.ok) {
        throw new Error(
          `Stock search API request failed: ${response.status} ${response.statusText}`
        );
      }
    
      let data: any;
      try {
        data = await response.json();
      } catch (e) {
        throw new Error("Stock search API returned invalid JSON");
      }
    
      console.log('handleStockSearch', data);
      return {
        content: [{ type: "text", text: JSON.stringify(data) }],
      };
    }
  • Zod schema for input validation of the stock_search tool.
    const stockSearchSchema = z.object({
      input: z.string().min(1, "搜索关键字不能为空"),
      count: z.number().int().positive().max(50).optional().default(10),
    });
  • Dispatch logic in the main handleToolRequest function that routes fund.stock_search calls to the specific handler.
    if (name === "fund.stock_search") {
      return await handleStockSearch(args);
    }
  • MCP tool definition including name, description, and input schema for registration in getAllTools().
    {
      name: 'fund.stock_search',
      description: '搜索股票信息,基于东方财富API',
      inputSchema: {
        type: 'object',
        properties: {
          input: { 
            type: 'string', 
            description: '搜索关键字,如股票代码、股票名称或拼音简称',
            minLength: 1
          },
          count: { 
            type: 'number', 
            description: '返回结果数量,默认10,最大50',
            minimum: 1,
            maximum: 50,
            default: 10
          }
        },
        required: ['input']
      }
    }
  • The getAllTools function that registers all available tools, including fund.stock_search.
    export const getAllTools = () => [
      {
        name: 'fund.echo',
        description: 'Echo back a message. Example interface for scaffold.',
        inputSchema: {
          type: 'object',
          properties: {
            message: { type: 'string', description: 'Text to echo back' }
          },
          required: ['message']
        }
      },
      {
        name: 'fund.knoewledge',
        description: '获取的知识库列表信息',
        inputSchema: {
          type: 'object',
          properties: {
            kw: { type: 'string', description: '关键词,支持模糊查询' },
            pageSize: { type: 'number', description: '每页数量,默认10' },
            pageNum: { type: 'number', description: '页码,默认1' }
          },
        }
      },
      {
        name: 'fund.stock_search',
        description: '搜索股票信息,基于东方财富API',
        inputSchema: {
          type: 'object',
          properties: {
            input: { 
              type: 'string', 
              description: '搜索关键字,如股票代码、股票名称或拼音简称',
              minLength: 1
            },
            count: { 
              type: 'number', 
              description: '返回结果数量,默认10,最大50',
              minimum: 1,
              maximum: 50,
              default: 10
            }
          },
          required: ['input']
        }
      }
    ];
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the API source but doesn't describe rate limits, authentication needs, error handling, or what happens when no results are found. For a search tool with external API dependencies, this leaves significant gaps in understanding its operational 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 extremely concise with a single sentence that directly states the tool's purpose and source. Every word earns its place, and there's no redundant or unnecessary information.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the search returns (e.g., stock codes, names, prices), how results are formatted, or any limitations of the API. For a tool with external dependencies and no structured output documentation, 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?

The schema description coverage is 100%, with both parameters ('input' and 'count') fully documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

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 clearly states the tool's purpose as '搜索股票信息' (search for stock information) with the specific source '基于东方财富API' (based on East Money API). It distinguishes from siblings like 'fund.echo' and 'fund.knoewledge' by focusing on stock search functionality. However, it doesn't explicitly differentiate from potential similar tools beyond the sibling list provided.

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 any prerequisites, limitations, or scenarios where other tools might be more appropriate. The agent must infer usage from the purpose 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/zhenzp/fund-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server