Blog

All Blog Posts  |  Next Post  |  Previous Post



Windows Service Deployment Guide for the HTTP.SYS-Ready MCP Server Built with TMS AI Studio

Monday, December 22, 2025

When you start working with TMS AI Studio and its MCP components, one of the most natural deployment targets you’ll eventually consider is a Windows service. A Windows service gives you a persistent, always-running environment where your MCP server can operate in the background without requiring a desktop session. With TMS AI Studio, and specifically with TTMSMCPServer, setting this up becomes far more straightforward than you might expect.
TMS Software Delphi  Components tmsaistudio
In this guide, we’ll walk through the process of creating a Windows service in Delphi, embedding a TTMSMCPServer inside it, and configuring the server so that it can stream responses and handle MCP tool invocations. You don’t need IIS, Apache, or any external web server: when deployed on Windows, the MCP server automatically uses HTTP.SYS, Windows' own kernel-mode HTTP stack. This not only provides a stable, high-performance backend without additional infrastructure, but also allows the server to inherit the machine’s existing HTTPS configuration. Because HTTP.SYS manages TLS at the operating-system level, your service can rely on the certificates and bindings already registered on the machine, letting you enable secure HTTPS endpoints without shipping or managing certificates inside your application.

Creating the Windows Service Project

The first step is to let Delphi generate a service application for us. This is done by selecting File → New → Other → Delphi Projects → Service Application. Delphi will generate a class descending from TService along with the standard service registration glue code. This project will compile into an executable that Windows can install and run as a real service.

The key moment is understanding that your entire MCP server lifecycle should be contained inside the ServiceStart and ServiceStop methods. Whatever you start in ServiceStart should be stopped cleanly in ServiceStop. This balance ensures that Windows can start and stop the service repeatedly without leaving sockets open or threads hanging around.

When Delphi generates the service, most of the scaffolding is already in place. What matters is adding our MCP server object so that it lives as long as the service is running.

Embedding TTMSMCPServer into the Service

TMS AI Studio’s TTMSMCPServer is the main class that exposes the MCP protocol and allows clients to communicate with your application. The component is designed to be lightweight, self-contained, and easy to configure through both constructor parameters and a builder pattern.

Inside ServiceStart, we typically create the MCP server instance, configure it, and call its Start method. A basic example looks like this:

FServer := TTMSMCPServer.Create(nil); FServer.ServerName := 'MyMCPServer'; FServer.ServerVersion := '1.0.0';
FServer.Transport := TTMSMCPStreamableHttpTransport.Create(); FServer.Start;

However, TTMSMCPServer also provides a fluent builder API, which makes the configuration phase cleaner, especially when enabling optional MCP capabilities. Through the builder, you can turn on tool notifications, resource notifications, prompt notifications, sampling support, adjust pagination settings, and more. For example:

FServer := TTMSMCPServer.CreateBuilder .Name('MyMCPServer') .ServerVersion('1.0.0') .EnableToolNotifications(True) .EnableResourceNotifications(True) .EnablePromptNotifications(True) .EnableSampling(True) .Build;

Once created, calling Start activates the server and binds it to its HTTP endpoint.

One of the nicest design choices in the MCP server is that you do not need to configure HTTP.SYS or any other networking layer manually. On Windows, the server automatically uses HTTP.SYS, which means Windows itself handles the HTTP listener, manages kernel-mode request queues, and provides robust throughput without requiring IIS. You simply start the server — and Windows does the rest.

Adding Tools and Streamable Handlers

An MCP server is not very useful until you define tools and handlers that clients can call. Tools are the MCP equivalent of JSON-RPC methods. They can return data immediately or even provide streamed results if your tool supports it.

Inside your service class, you assign event handlers such as OnListTools. This event is where you describe all the tools your server exposes. A simple example is a tool that returns the current time:

procedure TMyService.HandleListTools(Sender: TObject; const ToolList: TTMSMCPToolsCollection); var Tool: TTMSMCPTool; begin Tool := TTMSMCPTool.Create; Tool.Name := 'GetServerTime'; Tool.Description := 'Returns the current server date/time'; Tool.Method := DoTime; ToolList.Add(Tool); end;

The actual method (DoTime) does not receive any arguments and returns the current machine time as a TValue, which TTMSMCPServer will serialize back to the MCP client.

If you want to support streaming responses — such as sending incremental output, chunked data, or long-running progress — the MCP framework inside TMS AI Studio has built-in support for that as well. Streamable responses are especially useful when interacting with AI models, long computations, or processes that produce staged output.

You can also assign logging handlers, resource providers, prompt handlers, and other features described in the TTMSMCPServer documentation. The server is fully extensible and supports the entire MCP specification through its events and builder configuration.

Starting and Stopping the Server

In the ServiceStart method, after configuring the server, you call:

FServer.Start;

This triggers the creation of the HTTP listener and readies the MCP environment. When the Windows service is stopped, the ServiceStop method executes, and you simply shut the server down and free it:

FServer.Stop; FServer.Free;

This pattern ensures that:

  • The HTTP endpoint is released correctly

  • All ongoing MCP sessions are shut down properly

  • Windows can restart the service without errors

A well-behaved service is predictable and easy to deploy — and this pattern ensures exactly that.

Installing and Running the Service 


TMS Software Delphi  Components tmsaistudio

Once compiled, the service executable can be installed through standard Windows mechanisms. You can either implement installer logic in the service itself or install it using the command line via sc create. After installation, start the service either through the Services manager or through:

sc start MyMCPService

At that moment, Windows launches your executable, triggers ServiceStart, and your MCP server becomes available through its HTTP endpoint immediately. Since HTTP.SYS is doing the heavy lifting, you inherit all of its benefits: efficient request queuing, kernel-level performance, and stability even under load.

Final Thoughts

By combining Delphi’s Windows service framework with TMS AI Studio’s TTMSMCPServer, you get a clean and robust foundation for running an MCP server in production. The service runs invisibly in the background, accepts MCP/JSON-RPC clients, handles tools, resources, and prompts, and can stream output — all while relying on the built-in HTTP.SYS infrastructure.

This makes the deployment extremely lightweight, removes the need for external process managers, and offers a predictable service lifecycle. Whether you’re integrating AI processing, providing automation tools, or building internal development utilities, running TTMSMCPServer inside a Windows service is one of the most reliable ways to host MCP capabilities on a Windows machine.

If you want a ready-to-compile example project or a downloadable template, just let me know — I can generate a full skeleton service project with all the code pre-wired.

Start Building the Future Today

The AI revolution is here, and with TMS AI Studio, Delphi developers are perfectly positioned to be at the forefront. Whether you're building intelligent business applications, creating AI-powered tools, or exploring the possibilities of the Model Context Protocol, TMS AI Studio gives you everything you need to succeed.

Ready to transform your development process?

Starting at 225 EUR for a single developer license, TMS AI Studio offers exceptional value for the comprehensive AI development toolkit it provides.

Get TMS AI Studio Now →

Join the growing community of developers who are already building tomorrow's AI applications with TMS AI Studio. The future of intelligent software development starts here.

TMS Software Delphi  Components


TMS AI Studio requires Delphi 11.0 or higher. 



Bradley Velghe


  1. Add AI superpower to your Delphi & C++Builder apps part 1

  2. Add AI superpower to your Delphi & C++Builder apps part 2: function calling

  3. Add AI superpower to your Delphi & C++Builder apps part 3: multimodal LLM use

  4. Add AI superpower to your Delphi & C++Builder apps part 4: create MCP servers

  5. Add AI superpower to your Delphi & C++Builder apps part 5: create your MCP client

  6. Add AI superpower to your Delphi & C++Builder apps part 6: RAG

  7. Introducing TMS AI Studio: Your Complete AI Development Toolkit for Delphi

  8. Automatic invoice data extraction in Delphi apps via AI

  9. AI based scheduling in classic Delphi desktop apps

  10. Voice-Controlled Maps in Delphi with TMS AI Studio + OpenAI TTS/STT

  11. Creating an n8n Workflow to use a Logging MCP Server

  12. Supercharging Delphi Apps with TMS AI Studio v1.2 Toolsets: Fine-Grained AI Function Control

  13. AI-powered HTML Reports with Embedded Browser Visualization

  14. Additional audio transcribing support in TMS AI Studio v1.2.3.0 and more ...

  15. Introducing Attributes Support for MCP Servers in Delphi

  16. Using AI Services securely in TMS AI Studio

  17. Automate StellarDS database operations with AI via MCP

  18. TMS AI Studio v1.4 is bringing HTTP.sys to MCP

  19. Windows Service Deployment Guide for the HTTP.SYS-Ready MCP Server Built with TMS AI Studio

  20. Extending AI Image Capabilities in TMS AI Studio v1.5.0.0

  21. Try the Free TMS AI Studio RAG App



This blog post has not received any comments yet.



Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post