my-mcp-server
A minimal starter template for building Model Context Protocol (MCP) servers using TypeScript and FastMCP, including an example weather tool for demonstration.
README
<div align="center">
<img src="https://files.catbox.moe/vumztw.png" alt="ADK TypeScript Logo" width="100" />
<br/>
MCP Server Starter Template
A minimal starter template for building Model Context Protocol (MCP) servers using TypeScript and FastMCP.
MCP • FastMCP • TypeScript
</div>
A minimal starter template for building Model Context Protocol (MCP) servers using TypeScript and FastMCP.
Features
- Basic project structure with
src/lib,src/services,src/tools. - TypeScript setup (compiles to
dist/). fastmcpfor MCP server implementation.- A weather service example demonstrating:
- Proper folder structure (lib, services, tools)
- API integration with error handling
- Parameter validation using Zod
- Separation of concerns
- GitHub Actions workflows for CI and Release (manual trigger by default).
Getting Started
The easiest way to create a new MCP server project using this template is with the ADK CLI:
npm install -g @iqai/adk-cli # if you haven't already
adk new --template mcp-starter my-mcp-server
cd my-mcp-server
pnpm install
You can also use this template directly by copying the files, but using the CLI is recommended for best results.
Running the Server
Default (Production/Development) Route
To run your MCP server in production or for standard development, use:
pnpm dev
Fast Iteration & Agent Setup (ADK CLI)
For rapid prototyping, interactive testing, or initial agent setup, use the ADK CLI:
adk run # Interactive CLI chat with your agents
adk web # Web interface for easy testing and demonstration
-
Configure environment variables: For the weather service example, you'll need an OpenWeather API key:
# Create a .env file (add to .gitignore) echo "OPENWEATHER_API_KEY=your_api_key_here" > .envGet an API key from OpenWeather.
-
Initial Commit: It's a good idea to make an initial commit at this stage.
git add . git commit -m "feat: initial project setup from template" -
Develop your server:
- Add your custom tools in the
src/tools/directory. - Implement logic in
src/lib/andsrc/services/. - Register tools in
src/index.ts.
- Add your custom tools in the
Example Weather Tool
This template includes a weather service example that demonstrates:
-
HTTP Utilities (
src/lib/http.ts):- Type-safe HTTP requests with Zod validation
- Error handling
-
Configuration (
src/lib/config.ts):- Environment variable management
- Service configuration
-
Weather Service (
src/services/weather-service.ts):- API integration
- Data transformation
- Proper error propagation
-
Weather Tool (
src/tools/weather.ts):- Parameter validation with Zod
- User-friendly output formatting
- Error handling and user guidance
To use the weather tool:
# Set your OpenWeather API key
export OPENWEATHER_API_KEY=your_api_key_here
# Run the server
pnpm run start
# Connect with an MCP client and use the GET_WEATHER tool
# with parameter: { "city": "London" }
Release Management (Changesets)
This template is ready for release management using Changesets.
-
Install Changesets CLI (if not already in devDependencies): The template
package.jsonshould include@changesets/cli. If not:pnpm add -D @changesets/cli -
Initialize Changesets: This command will create a
.changesetdirectory with some configuration files.pnpm changeset init # or npx changeset initCommit the generated
.changesetdirectory and its contents. -
Adding Changesets During Development: When you make a change that should result in a version bump (fix, feature, breaking change):
pnpm changeset add # or npx changeset addFollow the prompts. This will create a markdown file in the
.changesetdirectory describing the change. Commit this changeset file along with your code changes. -
Publishing a Release: The GitHub Actions workflow
release.yml(inmcp-server-starter/.github/workflows/) is set up for this. When you are ready to release:- Ensure all feature PRs with their changeset files are merged to
main. - Important: Before publishing, ensure your
package.jsonis complete. Add or update fields likekeywords,author,repository(e.g.,"repository": {"type": "git", "url": "https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git"}),bugs(e.g.,"bugs": {"url": "https://github.com/YOUR_USERNAME/YOUR_REPO_NAME/issues"}), andhomepage(e.g.,"homepage": "https://github.com/YOUR_USERNAME/YOUR_REPO_NAME#readme") for better discoverability and information on npm. - The
release.ymlworkflow (manually triggered by default in the template) will:- Run
changeset versionto consume changeset files, updatepackage.jsonversions, and updateCHANGELOG.md. It will push these to achangeset-release/mainbranch and open a "Version Packages" PR. - Merge the "Version Packages" PR.
- Upon merging, the workflow runs again on
main. This time, it will runpnpm run publish-packages(which should includechangeset publish) to publish to npm and create GitHub Releases/tags.
- Run
- To enable automatic release flow: Change
on: workflow_dispatchinrelease.ymltoon: push: branches: [main](or your release branch).
- Ensure all feature PRs with their changeset files are merged to
Available Scripts
pnpm run build: Compiles TypeScript to JavaScript indist/and makes the output executable.pnpm run dev: Runs the server in development mode usingtsx(hot-reloading for TypeScript).pnpm run start: Runs the built server (fromdist/) using Node.
Rapid Development Setup
For fast iteration during development, use the dev script with hot reload:
pnpm run dev
This runs tsx watch src/index.ts which automatically restarts the server when you make changes to your TypeScript files.
MCP Client Configuration for Development
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"weather-dev": {
"command": "/Users/marvelsmbp/Documents/OSS/my-mcp-server/node_modules/.bin/tsx",
"args": ["watch", "/Users/marvelsmbp/Documents/OSS/my-mcp-server/src/index.ts"],
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here"
}
}
}
}
Claude Desktop: Add a development server entry with:
- Command:
/Users/marvelsmbp/Documents/OSS/my-mcp-server/node_modules/.bin/tsx - Args:
["watch", "/Users/marvelsmbp/Documents/OSS/my-mcp-server/src/index.ts"] - Env:
OPENWEATHER_API_KEY=your_api_key_here
Development Workflow
- Start development server:
pnpm run dev - Configure MCP clients to use the
tsx watchcommand (see configs above) - Edit TypeScript files in
src/- changes auto-restart the server - Test in Cursor/Claude - tools reflect changes immediately
- For production: Switch clients back to
node dist/index.jsand runpnpm run build
Testing Your MCP Server
Option 1: Direct MCP Server Usage Use the server directly with MCP clients or integrate it into other applications.
Option 2: With ADK CLI (For Client-Side Testing) While this template creates an MCP server, you can create a simple client to test it:
-
Install the ADK CLI globally:
npm install -g @iqai/adk-cli -
Create a simple agent that uses your MCP server (in a separate test directory):
# In a test directory, create an agents/agent.ts file that connects to your MCP server adk run # Test the integration adk web # Web interface for testing
This approach is useful for testing how your MCP server tools work within the ADK ecosystem.
Using the Server
After building (pnpm run build), you can run the server:
- Directly if linked or globally installed:
mcp-hello-server(or your customized bin name). - Via node:
node dist/index.js - Via
pnpm dlx(once published):pnpm dlx your-published-package-name
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。