gmat-mcp-server
Enables AI agents to autonomously write, run, and debug NASA GMAT mission scripts, with tools for script execution, curated knowledge of common pitfalls, and semantic documentation search.
README
GMAT MCP Server
An MCP (Model Context Protocol) server that turns NASA's GMAT (General Mission Analysis Tool) into a tool an AI agent can actually use — not just talk about. Any MCP client (Claude Code, Claude Desktop, Cursor, custom apps) gets:
runGmat— the validation loop. Runs a GMAT mission script headless viaGmatConsoleand returns a classified outcome (completed | parse | convergence | run) with extracted errors and report-file contents. The agent writes a script, runs it, reads what broke, and fixes it — the same loop a mission designer uses.getGmatIdioms— curated knowledge. A hand-built knowledge base of GMAT gotchas discovered through that loop (cumulativeElapsedSecs, no parentheses in conditionals,Propagate Synchronizedfor two-spacecraft burns, …), so the agent stops making the classic mistakes.listGmatSamples/getGmatSample— known-good templates. The NASA sample-script corpus as a retrieval source for vetted mission patterns, plus an optional local corpus of community scripts (harvested from public repos, kept only if they pass a headlessrunGmatvalidation; listed with acommunity/prefix). The harvested corpus stays local — it is gitignored because licenses vary.searchDocs— semantic search over the GMAT documentation, embedded locally and cached indata/embeddings.json.
Example of what this enables: asked for a two-burn phasing rendezvous (700 km circular orbit, 30° separation), the agent derived the textbook solution, verified it exactly under two-body dynamics, discovered it misses by 47 km under J2 gravity by actually running it, and re-targeted the burns with GMAT's differential corrector to converge at 2.96 km — autonomously, in a handful of tool calls.
Requirements
- Node.js 18+ (ESM)
- pnpm (project uses
pnpm@10perpackage.json) - A local GMAT install (R2025a tested) — for the
runGmatand sample tools - An OpenAI API key — only if you want to rebuild the docs-search cache from scratch; the repo ships a prebuilt
data/embeddings.jsonand queries are embedded with a local model
Quick Start
- Clone the repo
git clone https://github.com/ginomoretta-creator/gmat-mcp-server.git
cd gmat-mcp-server
- Install dependencies
pnpm install
- Configure environment
Create a
.env.localat the repo root pointing at your GMAT install:
echo "GMAT_BIN=C:\Path\To\GMAT_R2025a\bin" > .env.local
See .env.example for all variables. The server loads .env.local / .env from the repo root automatically, so it works even when an MCP client spawns it with an empty environment.
- Build the project
pnpm build
- (Optional) Rebuild the docs cache from the live docs — requires
OPENAI_API_KEYin.env.local; skip this to use the prebuilt cache
pnpm run setup
- Start the MCP server
pnpm start
The server runs over stdio and exposes the searchDocs tool to your MCP client.
Scripts
- pnpm build: compile TypeScript to
dist/ - pnpm start: run server from
dist/index.js(loads.env.local) - pnpm dev: run server in watch mode with
ts-node - pnpm run setup: build cache from live docs (requires OpenAI API key)
- pnpm run setup:test: build a smaller test cache using
pages-test.json
Pass --force to setup to rebuild the cache from scratch:
pnpm run setup -- --force
Environment Variables
- GMAT_BIN (required for
runGmat/samples): GMATbinfolder containingGmatConsole(.exe) - GMAT_SAMPLES (optional): samples dir (default:
<GMAT_BIN>\..\samples) - GMAT_IDIOMS (optional): idioms file (default:
./data/gmat_idioms.md) - OPENAI_API_KEY (setup only): used to rebuild the docs-embedding cache
- CACHE_DIR (optional): directory for
embeddings.json(default:./data) - BASE_URL (optional): docs base URL (default:
https://documentation.help/gmat/) - NODE_ENV (optional): set to
testto usepages-test.jsonduring setup - MCP_PORT (optional): for wrappers/adapters that expose this stdio server via TCP/SSE. This server itself communicates over stdio and does not bind to a port; some clients or adapters may read
MCP_PORTto decide which port to listen on.
Files read for env values:
- Setup reads both
.envand.env.local - Runtime reads
.env.local(viapnpm start) or your shell env
Using with MCP Clients
Claude Code
claude mcp add gmat -- node C:\path\to\gmat-docs-mcp-server\dist\index.js
(.env.local at the repo root is picked up automatically.)
Other stdio clients
This server communicates via stdio. Point your MCP client to execute the server in your project directory. Two common approaches:
Option A: Use the start script
pnpm start
Your MCP client should spawn this command in the repo root (ensures .env.local is picked up).
Option B: Use the wrapper
There is a convenience wrapper that ensures env loading, then starts the compiled server:
node start-mcp.js
Note: If you run the server behind an adapter that serves MCP over SSE/TCP, you can set MCP_PORT to guide that adapter. The server code here still talks over stdio.
Tool: searchDocs
Inputs:
query(string, required)topK(number, default 10, 1–50)minScore(number, default 0.1, 0–1)
Output: formatted text with page name, source URL, similarity score, and extracted content.
GMAT copilot tools (execution + knowledge)
Beyond doc search, the server exposes the GMAT validation loop and curated knowledge so an MCP client (Claude) can write → run → diagnose → fix GMAT missions autonomously:
runGmat— runs a GMAT.script(passed as text) headless viaGmatConsole.exeand returns{ ok, stage, errors, reports, raw_tail }.stage∈completed | parse | convergence | run. Inputs:script(string, required),timeoutSec(number, default 600 — raise for multi-day low-thrust propagations). This is the closed validation loop.getGmatIdioms— returns the curated GMAT idioms/gotchas knowledge base (data/gmat_idioms.md). Read it before generating scripts to avoid common pitfalls.listGmatSamples— lists the bundled NASA sample.scriptnames (a retrieval corpus of known-good patterns).getGmatSample— returns one sample's full text by name, to seed a phase from a vetted template.
These require a local GMAT install; see GMAT_BIN / GMAT_SAMPLES / GMAT_IDIOMS in
.env.example (defaults match a standard GMAT R2025a install).
Data and Cache
- Cache file:
data/embeddings.json(or${CACHE_DIR}/embeddings.json) - To rebuild:
pnpm run setup -- --force - To use a smaller test set:
pnpm run setup:test
Customizing Pages
The list of pages to scrape is defined in:
pages.json(full set)pages-test.json(smaller set for tests)
You can edit these files to change the crawl scope. The parser attempts to extract meaningful sections by headings and convert them to Markdown for embedding.
Troubleshooting
- Error: OPENAI_API_KEY environment variable is required
- Create
.env.local(and optionally.env) withOPENAI_API_KEY
- Create
- Cache not found at data/embeddings.json. Run setup first.
- Run
pnpm build && pnpm run setupto generate the cache
- Run
- Network timeouts while scraping
- The scraper retries with exponential backoff; rerun
setupor adjust your network
- The scraper retries with exponential backoff; rerun
- MCP client can’t see tools
- Ensure the server is started from the project directory and connected via stdio
- Confirm
pnpm startlogs show the server is running and the cache is loaded
Project Structure
src/
index.ts # MCP server entry (stdio)
setup.ts # Setup pipeline: scrape → parse/chunk → embed → cache
tools/ # MCP tool definitions and handlers
utils/ # scraper, parser, embedder, cache, search
data/ # Default cache directory (embeddings.json)
pages.json # Full list of pages to scrape
pages-test.json # Smaller list for testing
dist/ # Compiled JavaScript (after pnpm build)
start-mcp.js # Wrapper to load env and run the server
Credits
The documentation-search foundation (scrape → parse/chunk → embed → cache pipeline) was originally built by Ignacio García as gmat-docs-mcp-server. The GMAT execution copilot tools (runGmat, idioms knowledge base, sample corpus) and the local-embedding runtime were added on top.
License
ISC
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。