techContext.md•2.15 kB
# Technical Context: Marketstack MCP Server
## Technologies Used
- **TypeScript:** Primary language for server development.
- **Node.js:** Runtime environment for the server.
- **@modelcontextprotocol/sdk:** Core library for building the MCP server.
- **Zod:** Library for defining and validating tool input schemas.
- **Native Fetch API:** Used for making HTTP requests (requires Node.js 18+).
- **lru-cache:** Used for implementing the in-memory LRU cache, centralized in the `MarketstackClient` for all tool results.
- **MarketstackClient:** Custom client module that centralizes all Marketstack API calls and manages caching, API key usage, and request deduplication.
## Development Setup
- **Prerequisites:** Node.js (version 18 or higher recommended), npm or yarn.
- **Installation:** Clone the repository, navigate to the project directory, and run `npm install` or `yarn install`.
- **Configuration:** Set the `MARKETSTACK_API_KEY` environment variable with a valid Marketstack API key.
- **Building:** Compile the TypeScript code using `tsc`.
- **Running:** Execute the compiled JavaScript code (`node dist/index.js`).
## Technical Constraints
- **Marketstack API Limits:** Adherence to Marketstack API rate limits and usage policies is required.
- **Node.js Version:** Requires Node.js 18+ for native fetch support.
- **Excluded Endpoints:** Specific real-time, commodity, and company ratings endpoints were intentionally excluded from the initial implementation scope.
- **Cache Size:** The LRU cache in `MarketstackClient` has a maximum size to prevent excessive memory consumption.
## Dependencies
- `@modelcontextprotocol/sdk`
- `zod`
- `typescript`
- `lru-cache`
- Development dependencies (e.g., testing frameworks, linters, formatters) are managed via `package.json`.
## Additional Notes
- **Dependency Injection:** All tool handlers receive the shared `MarketstackClient` instance, promoting testability and separation of concerns.
- **Centralized Caching:** Caching is handled exclusively by the client, keyed by API parameters only.
- **Licensing:** The project is licensed under the GNU General Public License v3.