Skip to main content
Glama
JingHao-Leon

mcp-stock-quote

by JingHao-Leon

mcp-server-template

License: MIT Node.js ≥ 18 TypeScript MCP

mcp-server-template connects MCP clients like Claude Desktop and Cursor to three stock markets, weather, RSS and local files through one stdio server — no API keys required

A batteries-included TypeScript template for building MCP servers — clone it, add one file, and your tool is live in Claude Desktop, Cursor, or Kimi Code.

mcp-server-template is a Model Context Protocol (MCP) server scaffold built on the official @modelcontextprotocol/sdk. It ships with 6 working examples covering the three MCP primitives (tools, resources, prompts) and the patterns you'll actually need: JSON APIs, non-JSON text APIs, XML feeds, and local file access. All data sources are free and key-less, so every example runs the moment you clone.

"The Model Context Protocol is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools." — Anthropic, introducing MCP

English · 中文说明

Contents: Why this template · Included examples · Quick start · Architecture · Add your own tool · Project structure · FAQ

Why this template

  • One file = one tool group: drop a file into src/tools/, register it in one line, done

  • Real examples, not stubs: stock quotes (A-share/HK/US), weather, RSS reader, file word count — each demonstrating a different integration pattern

  • Beyond tools: working Resource and Prompt examples most templates skip

  • Testable by design: business logic lives in src/lib/, decoupled from the MCP protocol

  • Grows with you: start as one server; the docs show how to split into multiple servers or a monorepo when you outgrow it

Related MCP server: Stock MCP Server

Included examples

Tool / Capability

What it does

Pattern it teaches

get_stock_quote

Realtime quotes for A-share, HK, US stocks

Text-based API, GBK decoding, batch input, graceful errors

search_stock

Search stocks by name / pinyin / code

Query normalization, unicode escaping

get_current_weather

Current weather for any city

Chained JSON API calls (geocode → forecast)

read_rss_feed

Latest entries from any RSS/Atom feed

XML fetching & parsing

count_file_words

Line/word/char count of a local file

Filesystem access & safety limits

Resource info://server

Server metadata as JSON

Exposing read-only data

Prompt stock_briefing

One-click stock comparison report

Prompt templates that orchestrate tools

Data sources: Tencent quote API (stocks) and Open-Meteo (weather) — both free, no API key.

Quick start

Requires Node.js ≥ 18.

# Click "Use this template" on GitHub, or clone directly:
git clone https://github.com/JingHao-Leon/mcp-server-template.git
cd mcp-server-template
npm install
npm run build

Connect your MCP client

Claude Desktop / Cursor — add to your mcpServers config:

{
  "mcpServers": {
    "my-tools": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-template/dist/index.js"]
    }
  }
}

Kimi Code:

kimi mcp add my-tools -- node /absolute/path/to/mcp-server-template/dist/index.js

Then try: "查一下茅台和苹果的实时行情" or "Read https://hnrss.org/frontpage and summarize the top stories".

Add your own tool

Three steps, ~5 minutes — full walkthrough in CONTRIBUTING.md:

// src/tools/my-tool.ts
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

export function registerMyTools(server: McpServer): void {
  server.registerTool(
    "my_tool",
    {
      description: "What it does and when to use it",
      inputSchema: { input: z.string().describe("...") },
    },
    async ({ input }) => ({
      content: [{ type: "text" as const, text: `result: ${input}` }],
    }),
  );
}
// src/tools/index.ts — one line:
registerMyTools(server);

npm run build, restart your client, and the AI can call it.

Architecture

Clients talk to the server over stdio (JSON-RPC); the server fans out to free data sources. Each box in src/tools/, src/resources/, and src/prompts/ is one file — copy it to add your own capability.

Architecture: MCP clients (Claude Desktop, Cursor, Kimi Code) call 5 tools, 1 resource and 1 prompt in the server over stdio; the server fetches from Tencent quote API, Open-Meteo, RSS feeds and the local filesystem — all without API keys

Project structure

src/
├── index.ts        # entry: creates the server, registers everything
├── tools/          # one file = one tool group (the pattern to copy)
├── lib/            # business logic, decoupled from MCP — unit-test it directly
├── resources/      # Resource example
└── prompts/        # Prompt example
docs/
└── multi-server.md # when & how to split into multiple servers / a monorepo
CONTRIBUTING.md     # the 5-minute "add a tool" guide

FAQ

Do the examples need any API key? No. Stocks come from Tencent's public endpoints, weather from Open-Meteo. Everything runs immediately after npm install && npm run build.

Which MCP clients work with this? Any client supporting stdio MCP servers: Claude Desktop, Cursor, Kimi Code, and others.

How do I test my tool without a client? Call the lib/ functions directly with node --input-type=module -e, or run the JSON-RPC smoke test in CONTRIBUTING.md.

When should I split my server into multiple servers? When you exceed ~20 tools, have different trust boundaries, or need remote deployment. See docs/multi-server.md.

Can I use this commercially? Yes, MIT licensed. Note the bundled stock data source is unofficial and has no SLA — swap in a licensed feed (iFinD, Polygon, Finnhub) for production.


Last updated: 2026-09-02. This repo ships an llms.txt so AI agents can consume the project structure directly.

License

MIT


中文说明

一个开箱即用的 TypeScript MCP server 模板:clone 下来、加一个文件,你的工具就能在 Claude Desktop / Cursor / Kimi Code 里被 AI 直接调用。

模板里有什么

  • 6 个可直接运行的示例:股票行情(A股/港股/美股)、股票搜索、天气、RSS 阅读、文件统计,外加 Resource 和 Prompt 示例

  • 每个示例教一种模式:标准 JSON API、非 JSON 文本接口(GBK 解码)、XML 抓取、本地文件访问

  • 数据源全部免费免 key:腾讯行情 + Open-Meteo,clone 即可跑

  • 可测试的架构:业务逻辑在 src/lib/,不依赖 MCP 协议,可单独测试

  • 扩展路径清晰:单服务起步,需要时按 docs/multi-server.md 拆成多服务或 monorepo

快速开始

git clone https://github.com/JingHao-Leon/mcp-server-template.git
cd mcp-server-template && npm install && npm run build

在 MCP 客户端的 mcpServers 配置中加入:

{
  "mcpServers": {
    "my-tools": {
      "command": "node",
      "args": ["/绝对路径/mcp-server-template/dist/index.js"]
    }
  }
}

添加自己的工具

  1. src/tools/ 新建文件,仿照示例写一个 registerXxxTools(server) 函数

  2. src/tools/index.ts 里 import 并调用一行

  3. npm run build,重启客户端

详细指南见 CONTRIBUTING.md

数据源说明

股票行情来自腾讯公开接口(qt.gtimg.cn),非官方授权 API,无 SLA,仅供个人使用;天气数据来自 Open-Meteo。商用请替换为授权数据源。

Available Tools

5 tools
count_file_wordsA

统计一个本地文本文件的行数、词数和字符数(类似 wc)。仅支持纯文本文件。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes文件路径,如 /tmp/notes.txt

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses that the operation is a read-only count and restricts to plain text files. However, it does not clarify edge cases such as encoding handling, word definition conventions, or behavior on missing/unreadable files, which would make the behavior fully transparent.

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?

Two short Chinese sentences deliver all essential information with zero waste. The core function and the 'like wc' comparison appear first, and the plain-text constraint follows immediately. Perfectly front-loaded and concise.

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

Completeness4/5

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

For a simple, read-only counting tool, the description sufficiently explains what the tool does and its key constraint. Since there is no output schema, the agent might not know the exact return JSON structure, but the counts are named explicitly and 'like wc' gives a strong hint. Minor gaps around error handling and return format prevent a 5.

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

Parameters4/5

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

The schema covers 100% of the single parameter with a clear example. The description adds value beyond the schema by specifying the file must be local and plain text, constraining what kind of path is acceptable. This goes beyond the bare schema description.

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

Purpose5/5

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

The description uses a specific verb (统计/count) and resource (本地文本文件的行数、词数和字符数), explicitly comparing to 'wc'. This makes the tool's function unmistakable and clearly distinct from unrelated siblings like stock quotes or weather.

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

Usage Guidelines4/5

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

The description clearly implies when to use the tool (when counting lines/words/characters of a text file) and includes an explicit limitation ('仅支持纯文本文件'), which warns against non-plain-text inputs. It does not name alternatives, but the sibling tools are so unrelated that no routing guidance is necessary.

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

get_current_weatherA

查询指定城市的当前天气(温度、湿度、天气现象、风速),数据源 Open-Meteo,无需 API key。

ParametersJSON Schema
NameRequiredDescriptionDefault
cityYes城市名,中英文均可,如 "北京"、"Shanghai"、"Tokyo"

TDQS

A4/5.0
Behavior3/5

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

无注解信息,描述自行说明了数据源为 Open-Meteo 且无需 API key,填补了认证和来源信息。但未说明城市不存在时的行为、数据时效性、异常处理或响应格式,行为披露仍不完整。

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?

单句描述,信息密度高,先说明核心功能,再列返回要素、数据源和鉴权要求,没有冗余内容。

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

Completeness4/5

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

对于只有一个参数且无输出 schema 的简单查询工具,描述已覆盖返回内容、数据源和鉴权要求,足以让代理理解如何调用。缺少输出结构示例和失败语义,但尚不构成严重缺口。

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 覆盖率为 100%,city 参数的中英文示例和最小长度已足够。描述未额外补充参数格式或约束,因此维持基线 3。

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

Purpose5/5

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

描述明确使用动词“查询”和资源“指定城市的当前天气”,并列出返回的具体要素(温度、湿度、天气现象、风速),与股票、RSS、文件字数等兄弟工具完全区分。

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

Usage Guidelines4/5

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

描述清楚说明该工具用于获取指定城市的实时天气,使用场景明确;同列兄弟工具均属其他领域,无需额外排除说明。但未显式提及“需要天气信息时使用”或何时不使用。

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

get_stock_quoteA

获取股票实时行情,支持 A股、港股、美股,可批量查询。代码格式灵活:A股可传 600519 / sh600519 / sz000001;港股可传 00700 / hk00700;美股传 AAPL / TSLA 等 ticker。若不确定代码,先用 search_stock 按名称搜索。

ParametersJSON Schema
NameRequiredDescriptionDefault
symbolsYes股票代码列表,如 ["600519", "hk00700", "AAPL"]

TDQS

A4.5/5.0
Behavior3/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 does communicate real-time data, market coverage, batch capability, and flexible symbol formats, but it does not describe the return shape, error behavior, or data-source caveats. This is adequate but not rich.

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 compact and well-structured: it front-loads the core purpose, then gives market-specific format guidance, then closes with a fallback routing instruction. Every sentence earns its place with no filler.

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

Completeness4/5

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

For a single-parameter quote tool, the description is nearly complete: it covers supported markets, code formats, batch behavior, limits in the schema, and the fallback to search_stock. The only notable gap is the lack of any description of the returned quote data, which matters because there is no output schema, but this does not prevent correct invocation.

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

Parameters5/5

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

Although the schema already documents the symbols array with 100% coverage, the description adds substantial meaning beyond the schema: exact symbol-format conventions for A-shares, HK stocks, and US tickers, plus the batch-query capability. This materially helps an agent construct valid inputs.

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

Purpose5/5

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

The description clearly states the tool retrieves real-time stock quotes for A-shares, HK, and US markets, and supports batch queries. It names the resource (stock quotes) and distinguishes itself from the sibling search_stock tool by being the quote-retrieval step after a code is known.

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

Usage Guidelines5/5

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

It explicitly provides when to use this tool versus search_stock: if the user is unsure of the stock code, search_stock should be used first. It also gives concrete code-format examples for each market, making the appropriate call pattern clear.

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

read_rss_feedA

读取 RSS/Atom 订阅源的最新条目(标题、链接、发布时间)。

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYes订阅源地址,如 https://example.com/feed.xml
limitNo返回条数,默认 10

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It discloses that the operation is a read and lists the returned fields, but does not mention network fetching behavior, error handling, caching, or what happens with invalid feeds. Basic behavior is covered, but edge cases are not.

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, front-loaded sentence that conveys the core purpose and return fields without waste. Every word earns its place.

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

Completeness4/5

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

Although there is no output schema, the description explicitly lists returned fields (title, link, publish time). The two parameters are fully documented in the schema, and the tool's simplicity means nothing critical is missing for an agent to call it correctly.

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 baseline is 3. The description does not add parameter-specific meaning beyond the schema, but the schema already documents both 'url' and 'limit' adequately.

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

Purpose5/5

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

The description states a specific verb ('read') and resource ('RSS/Atom feed'), and specifies what is returned (latest entries with title, link, publish time). This clearly distinguishes it from the unrelated sibling tools (stock quotes, weather, word counts).

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

Usage Guidelines4/5

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

The description clearly indicates the tool is for reading RSS/Atom feeds, so the use case is obvious. It does not explicitly mention alternatives or exclusions, but siblings are in different domains, so no such guidance is necessary.

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

search_stockB

按名称、拼音或代码片段搜索股票,返回股票代码及所属市场(A股/港股/美股)。

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo返回条数,默认 10
keywordYes搜索关键词,如 "茅台"、"腾讯"、"apple"

TDQS

B3.4/5.0
Behavior2/5

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

No annotations were provided, so the description carries the full burden of behavioral disclosure. It merely states the search action and returned data without revealing any additional traits such as fuzzy matching behavior, handling of ambiguous matches, sort order, or the fact that the operation is read-only. For a search tool this is a modest but notable gap.

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, dense sentence in Chinese that immediately conveys the core function and output. There is no filler or redundant repetition of parameter names. It earns its place entirely.

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

Completeness3/5

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

For a simple two-parameter search tool, the description covers the essential inputs and outputs (returned code and market). However, with no output schema and no annotations, the description doesn't fully specify the exact return format, possible empty-result behavior, or the effect of the limit parameter in practice. It is adequate for basic invocation but leaves some contextual gaps.

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

Parameters4/5

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

The schema already documents both parameters well (coverage 100%). The description adds value by specifying that 'keyword' can be a name, pinyin, or code fragment, which goes beyond the schema's examples ('茅台', '腾讯', 'apple'). This extra semantic nuance helps the agent understand the acceptable input range for the keyword parameter.

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 function: searching stocks by name, pinyin, or code fragment, and returning the stock code and market. The verb 'search' plus the resource 'stocks' is specific, and the supported search modes add useful detail. Although it doesn't explicitly differentiate from the sibling 'get_stock_quote', the naming and described output make the distinction obvious enough.

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

Usage Guidelines3/5

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

The description implies when to use the tool: when you need to find a stock code or market by a keyword like a name or code fragment. However, it offers no explicit guidance on when not to use it, nor does it mention that get_stock_quote is the appropriate sibling for retrieving price data. The examples in the schema hint at typical usage but don't formally establish selection criteria.

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

TDQS

A3.8/5.0
Disambiguation5/5

Every tool has a clearly distinct purpose: stock search, stock quote, weather, RSS, and file word count do not overlap. get_stock_quote and search_stock are complementary rather than competing.

Naming Consistency5/5

All tool names follow a consistent verb_noun snake_case pattern (get_stock_quote, search_stock, get_current_weather, read_rss_feed, count_file_words). The naming convention is uniform across the set.

Tool Count2/5

A stock-quote server only needs the two stock tools; the weather, RSS, and word-count tools are unrelated to the server's stated purpose. Five tools is not excessive by number, but the scope is muddled because most tools do not belong.

Completeness3/5

For stock quotes, search_stock plus get_stock_quote covers the core lookup-and-quote workflow, though historical data or market context is missing. The unrelated utility tools are each isolated one-off functions, so the overall surface is not fully complete for any coherent broader domain.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables querying financial data including stocks, indices, funds, and futures from Chinese, Hong Kong, and US markets. Provides real-time market information, financial indicators, news, and trading suggestions through Eastmoney and Sina data sources.
    13
    3
    ISC
  • A
    license
    B
    quality
    D
    maintenance
    Provides real-time market data for A-shares, Hong Kong, and US stocks using the Tencent Finance API. It enables users to manage stock positions and watchlists through an AI assistant.
    12
    20
    ISC
  • A
    license
    Not graded
    quality
    C
    maintenance
    Real-time A-share stock data for AI assistants. Provides real-time stock prices, K-line data, financial indicators, and sector fund flow analysis for Chinese A-share market. Multi-source data validation ensures accuracy.
    4
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to access comprehensive Chinese financial market data including stocks, funds, futures, and economic indicators via AKShare.
    5
    6
    MIT

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/JingHao-Leon/mcp-server-template'

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