The Deska blog
Building a Custom MCP Server in an Evening
Learn the essentials of building a custom MCP server to extend your AI tools. A step-by-step guide for developers using the Model Context Protocol.
10 min read
Building a custom MCP server has become a priority for developers who want to bridge the gap between Large Language Models and their local data or proprietary APIs. The Model Context Protocol (MCP) provides a standardized way for AI agents to interact with external tools and datasets. By following a structured approach, you can move from a concept to a functional server in a single evening, allowing your AI tools to read files, query databases, or trigger system actions.
Understanding the MCP Architecture
The Model Context Protocol works on a client-host-server relationship. The host is the application where you interact with the AI, such as an IDE or a specialized workspace. The client is the integration layer that communicates with the MCP server. The server acts as the gateway to the specific resource you want to expose.
Communication usually happens over standard input and output (STDIO) or HTTP using JSON-RPC. This simplicity means you can write a server in almost any language, though TypeScript and Python have the most robust SDK support. When you are building a custom MCP server, you are essentially defining three things: resources, prompts, and tools.
Resources are like read-only data sources. These could be local log files or documentation snippets. Prompts are reusable templates that help the AI understand how to interact with your data. Tools are the most dynamic part, as they allow the AI to perform actions like sending an email or executing code.
Setting Up Your Development Environment
To start, you need a clean environment. Most developers opt for the TypeScript SDK because of its strong typing, which is helpful when defining the JSON schemas for your tool arguments.
- Initialize a new Node.js project.
- Install the
@modelcontextprotocol/sdkpackage. - Configure your
tsconfig.jsonfor modern asynchronous JavaScript.
While you build, testing becomes the primary challenge. Traditional debuggers can be difficult to attach to STDIO processes. Many developers use the MCP Inspector, a utility provided by the protocol creators that simulates a client. In a more complex setup, you might use a tool like Deska to test how your server behaves within a real-world workflow. Deska is a free desktop app for Mac, Windows, and Linux that provides an infinite canvas workspace. Because it can run coding agents side by side in different panels, you can see how your MCP server responds to queries in one terminal while monitoring logs in another.
Implementing the Logic
The core of your server lies in the request handlers. You will need to define a list of tools that your server offers. Each tool needs a unique name, a description, and an input schema. The description is vital because the LLM uses it to decide when to call the tool.
If your description is vague, the AI might call the tool at the wrong time or with incorrect parameters. For example, if you are building a tool to search through a custom documentation folder, your tool definition might look like this:
- Name:
search_docs - Description: Searches the local technical documentation for specific keywords and returns the most relevant paragraphs.
- Parameters: A JSON schema defining a
querystring.
Once the tool is called, your code executes the search logic locally and returns a result object containing text or image content. Remaining local-first ensures that your data never leaves your machine unless you explicitly program the tool to send it to an external API.
Testing and Debugging
Once the code is written, you must register the server with an MCP-compliant host. For many, this is the Claude Desktop app, where you edit a configuration file to point to your server's executable.
| Feature | STDIO Transport | HTTP Transport |
|---|---|---|
| Use Case | Local development | Remote services |
| Setup Ease | High | Medium |
| Security | Process-based | Token/URL-based |
| Complexity | Low | High |
Debugging a server requires looking at the raw JSON-RPC messages. If the server fails to start, it is often due to a path error or a missing environment variable. When using terminals within a multitasking environment, you can run your build process in a dedicated pane to catch syntax errors immediately.
Expanding Context with Deska
As your MCP server grows in complexity, you might find that a single window is not enough to manage your development. Deska allows you to place panels anywhere and zoom out to see everything. This layout is particularly useful when building a custom MCP server because you can have your editor, your terminal, and a browser window showing the MCP documentation all visible at once.
You can also use Ask Deska, a voice and chat assistant, to help manage your workspace. It can open panels or run commands for you while your hands stay on the keyboard. If you need to check if your server is running correctly from another room, the mobile app lets you monitor your work through a secure relay. The devices pair directly, so no ports are exposed to the public internet, maintaining the security of your local setup.
FAQ
How to debug MCP server connection issues?
Connection issues are usually caused by incorrect paths in the host configuration file. Ensure the command used to start the server (like node or python) is in your system path and that all relative paths to your script are converted to absolute paths.
Can I run MCP servers on Windows?
Yes, MCP servers run on Windows, Mac, and Linux. When using Windows, be mindful of path separators in your configuration files; using double backslashes or forward slashes is often necessary to avoid escape character errors.
What is the best language for MCP development?
TypeScript is generally considered the best starting point due to the official SDK and its excellent support for JSON schema validation. However, Python is a strong alternative if your server involves heavy data science or machine learning libraries.
Getting Started with Your Local Workspace
Building a custom MCP server is a powerful way to make your AI tools more relevant to your specific workflow. Whether you are automating repetitive tasks or building a deep integration with your company's internal tools, the Model Context Protocol provides the framework you need.
To create an ideal environment for this type of development, you can use a local-first workspace that supports multiple AI agents side by side. Visit the download page to get the Deska app for your operating system and start organizing your development panels on an infinite canvas today.