# Custom Servers

### <https://github.com/Hallway-Inc/mcp-starter>

### MCP Starter - Model Context Protocol Server

This repository provides a TypeScript-based starter template for building Model Context Protocol (MCP) servers using Express.js and the official MCP SDK. The MCP starter demonstrates how to create a streamable HTTP server that can expose custom tools to AI assistants and other MCP-compatible clients.

The server supports multiple simultaneous connections through session management and provides both HTTP POST endpoints for tool execution and GET endpoints for Server-Sent Events (SSE) streaming. Built with modern TypeScript, the project includes comprehensive tooling with development scripts, type safety, and a clean modular architecture that makes it easy to extend with additional functionality.

### Getting Started & Development

To get started, clone the repository and install dependencies using `pnpm install` (or `npm install`). The project includes several npm scripts for different development workflows: use `pnpm dev` to run the server in watch mode with hot reloading during development, `pnpm start` to run the TypeScript source directly, or `pnpm build` followed by running the compiled JavaScript for production deployment. The server accepts a `--port=XXXX` command-line argument to customize the listening port (defaults to 8123).

Environment variables can be configured through a `.env` file, and the server will automatically load them on startup. The modular architecture allows you to easily add new tools by creating tool definition files in the `src/tools/` directory and registering them in the main server class.

### Features & Example Tools

The starter includes a complete weather tools implementation that demonstrates best practices for MCP tool development. The weather tools showcase two key functionalities: `get-alerts` for retrieving weather alerts by state code, and `get-forecast` for getting detailed weather forecasts by latitude/longitude coordinates. These tools integrate with the National Weather Service API and demonstrate proper error handling, input validation using Zod schemas, and structured response formatting.

The server architecture supports easy extension - you can add new tools by following the same pattern of creating tool definitions with proper input schemas, implementing the tool logic, and registering handlers in the server setup. The codebase also includes built versions of additional tools (email, product search, and store locator) in the build directory, providing examples of how to structure more complex integrations for production use cases.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hallway.gitbook.io/embed/advanced/model-context-protocol/custom-servers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
