🗓️ 21032026 2100

CUSTOM MCP SERVERS

Building your own MCP servers to expose internal tools, databases, and APIs to AI applications

When to Build a Custom Server

  • You have internal APIs or databases that no public MCP server covers
  • You want to give AI agents controlled access to private systems (CI/CD, internal dashboards, proprietary data)
  • You need custom business logic in how tools are exposed (e.g., row-level access control on queries)

SDK Setup

LanguagePackageInstall
TypeScript@modelcontextprotocol/sdknpm install @modelcontextprotocol/sdk
Pythonmcppip install mcp

Defining Tools

Tools are the most common primitive to implement. Each tool needs:

FieldPurposeExample
nameUnique identifier"query_database"
descriptionTells the LLM when/how to use it"Run a read-only SQL query against the analytics DB"
inputSchemaJSON Schema defining parameters{ "type": "object", "properties": { "sql": { "type": "string" } } }

TypeScript example:

server.tool(
"query_database",
"Run a read-only SQL query against the analytics DB",
{ sql: z.string().describe("The SQL query to execute") },
async ({ sql }) => {
const results = await db.query(sql);
return { content: [{ type: "text", text: JSON.stringify(results) }] };
}
);

Defining Resources

Resources expose data the client can read on demand.

TypeURI PatternExample
StaticFixed URIconfig://app-settings
DynamicURI template with parametersdb://users/{user_id}
List-basedServer provides a list clients can browseFile listings, table names

Transport Options

TransportWhen to UseSetup
stdioLocal dev, single-user, CLI toolsServer reads stdin / writes stdout
Streamable HTTPRemote deployment, multi-user, shared servicesServer exposes HTTP endpoint with optional SSE

Start with stdio for prototyping — it's simpler to debug. Move to HTTP when you need remote access or shared deployment.

Example Use Cases

Use CaseTools ExposedWhy Custom?
Database accessquery, describe_table, list_tablesRow-level security, read-only enforcement
Internal APIsget_user, create_ticket, fetch_metricsAuth handling, rate limiting, schema translation
CI/CD pipelinestrigger_build, get_build_status, list_deploymentsInternal Jenkins/GitHub Actions integration
Document searchsearch_docs, get_documentProprietary search index, access control

References