mcp-server-demo
MCPサーバーデモ (Python)
2つのツールを備えた、ゼロから構築したローカルMCPサーバーです:
weather(city)→ wttr.in経由での現在の天気query_db(sql)→ 読み取り専用のSQLite SELECTクエリ
1) セットアップ
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e .Related MCP server: Swiss Meteo MCP
2) MCPサーバーの実行
mcp-server-demoこれによりローカルサーバーが起動し、サンプル行を含む demo.db が自動的に作成されます。
3) MCPの手動クイックチェック (オプション)
MCP Inspectorがインストールされている場合:
npx @modelcontextprotocol/inspectorその後、ローカルのPythonサーバーに接続します。
4) OpenAI API統合オプション
環境変数ファイルをコピーし、キーを入力します:
cp .env.example .env1つのターミナルでサーバーを起動します。
2つ目のターミナルで以下を実行します:
python client_openai_api.py注: これは
http://localhost:8000/mcpを指すMCPツール定義を使用したOpenAI Responses APIを利用しています。
ツールの動作
weather(city: str)
気温、体感温度、湿度、風、および簡単な気象状況を含むJSON要約フィールドを返します。
query_db(sql: str)
SELECT ...クエリのみを許可します。行をJSONとして返します。
このスターターデモでは安全のため、SELECT以外のSQLは拒否されます。
プロジェクトファイル
server.py— FastMCPサーバー + ツール定義。client_openai_api.py— MCPツールを呼び出すことができるシンプルなOpenAI API呼び出し。pyproject.toml— 依存関係 + スクリプトのエントリポイント。
Available Tools
10 toolsanalyze_image_with_openaiC
Analyze an image file with an OpenAI vision-capable model.
Inputs: path (required), prompt (required), model. Returns: result
inspect_fileC
Return file metadata and content preview for text/csv/image workflows.
Inputs: path (required), preview_chars, include_base64. Returns: result
list_directoriesC
List directories directly inside a folder within MCP_FILE_OPS_ROOT.
Inputs: path. Returns: result
list_filesB
List files directly inside a folder within MCP_FILE_OPS_ROOT.
Inputs: path. Returns: result
make_directoryC
Create a directory inside MCP_FILE_OPS_ROOT.
Inputs: path (required). Returns: result
move_fileC
Move a file from source_path to destination_path inside MCP_FILE_OPS_ROOT.
Inputs: source_path (required), destination_path (required). Returns: result
move_files_by_globC
Move all files matching a glob pattern from source_dir into destination_dir.
Inputs: source_dir (required), pattern (required), destination_dir (required). Returns: result
query_dbA
Run a read-only SELECT query against local SQLite demo.db.
Inputs: sql (required). Returns: result
read_fileC
Read a UTF-8 text file inside MCP_FILE_OPS_ROOT.
Inputs: path (required). Returns: result
weatherB
Return current weather for a city using wttr.in.
Inputs: city (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools have distinct purposes, but there is some overlap between inspect_file and read_file (both provide file content), and move_file vs move_files_by_glob are similar in name and action.
Majority follow verb_noun pattern with underscores, but 'weather' is a lone noun and 'analyze_image_with_openai' is verbose and breaks the pattern.
10 tools is a reasonable number, but the server covers multiple unrelated domains (files, DB, weather, image), making it feel a bit scattered.
File operations lack delete/copy, DB only has read-only query, weather and image analysis are single-tool services. The surface is incomplete for any single domain.
Maintenance
Related MCP Connectors
An MCP server for weather information by @kulybaba
An MCP server for weather information by @kulybaba
Related MCP Servers
- FlicenseBqualityDmaintenanceA demonstration server showcasing MCP capabilities with basic tools including addition calculations and weather API integration for fetching city weather data.2-
- FlicenseCqualityDmaintenanceAn experimental MCP server that provides weather information tools, including temperature lookup via wttr.io, along with note-taking capabilities for learning MCP server development with GitHub Copilot.3-
- FlicenseNot gradedqualityDmaintenanceA demo MCP server that provides AI assistants access to live US weather data via the free National Weather Service API, offering forecast and alert tools without requiring an API key.-
- FlicenseNot gradedqualityDmaintenanceA lightweight MCP server providing tools for adding integers, getting current time, and fetching weather forecasts via wttr.in.-