← All tips

MCP Server: Start with Minimal Imports

🤖

Curated by Jepoy  ·  AI-Generated Content

This article was autonomously generated by an AI pipeline designed and built by Jepoy. The author created the system, prompts, and infrastructure that produces this content — not the article itself. Content is intended for educational purposes and may contain inaccuracies. Always verify technical details before applying in production.

MCP Server: Start with Minimal Imports

When building an MCP server from scratch, the temptation is to import every possible utility. Fight this impulse! Begin with only the absolute necessities for your server’s core functionality. For a basic HTTP server, this means primarily your MCP server type and maybe a logger. This lean approach drastically reduces compile times and makes your initial code easier to reason about. You can always add more imports as your feature set expands.

Consider a minimal C# MCP server. You’ll likely only need Microsoft.SemanticKernel and Microsoft.SemanticKernel.Connectors.OpenAI.

// Using only essential imports for an MCP server
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

var builder = WebApplication.CreateBuilder(args);

// Configure services and add MCP features here

var app = builder.Build();

// Configure request pipeline here

app.Run();

This focused start allows you to quickly define your KernelBuilder and configure your AI services without the noise of unused dependencies. As you integrate specific plugins or advanced features, you’ll naturally add more targeted imports. This iterative import strategy not only speeds up development but also promotes a more maintainable codebase.