Getting Started with the Model Context Protocol (MCP)
An introduction to MCP and how to build your first MCP server to connect AI models to your systems.
SmartTechLabs
SmartTechLabs - Intelligent Solutions for IoT, Edge Computing & AI
The Model Context Protocol (MCP) is an open standard, originally developed by Anthropic, for connecting AI assistants to external data sources and tools. In this guide, we’ll explore what MCP is and how to get started building MCP servers.
Update, November 2026
This article describes the 2025 protocol revisions and the v1 TypeScript SDK (@modelcontextprotocol/sdk, currently 1.32.x), and the code below still works with that package. Since January:
- Governance: Anthropic donated MCP to the Agentic AI Foundation, a Linux Foundation fund, in December 2025. Other vendors’ clients implement it.
- Specification: the current revision is 2026-07-28. It removes the
initializehandshake and protocol-level sessions; capabilities come fromserver/discoverand each request is self-contained. Long-running work and UI extensions (Tasks, MCP Apps) are optional extensions. - TypeScript SDK v2: released as 2.0.0 on 2026-07-27 (2.4.0 on npm at the time of writing). It is split into
@modelcontextprotocol/serverand@modelcontextprotocol/client, needs Node.js 20 or later and Zod 4, and replaces the low-levelsetRequestHandler(Schema, ...)pattern used below withMcpServer.registerTool()/registerResource()andserveStdio(). The SDK ships a codemod and an upgrade guide. For a new server, start with v2. - Compiler: TypeScript 7 no longer accepts
moduleResolution: "node", so thetsconfig.jsonbelow usesNode16.
Open Standard
What is MCP?
MCP provides a standardized way for AI models to:
| Capability | Description | Example |
|---|---|---|
| Discover | Find available tools and resources | List database tables |
| Query | Access external data sources | Read file contents |
| Execute | Perform actions in external systems | Send notifications |
| Negotiate | Agree on protocol version and features | Server declares its tools capability |
Think of it as an API standard specifically designed for AI-to-system communication.
Core Concepts
MCP Components
| Component | Purpose | Examples |
|---|---|---|
| Resources | Data sources AI can query | Database tables, file contents, API responses |
| Tools | Actions AI can execute | Create records, send notifications, trigger workflows |
| Prompts | Pre-defined templates | Structured interaction patterns |
Building Your First MCP Server
Let’s build a simple MCP server in TypeScript that provides access to a list of tasks. It uses the low-level Server class so that the protocol messages are visible; the higher-level McpServer class is shorter for real projects.
Project Setup
This section uses the v1 SDK. npm install @modelcontextprotocol/sdk installs 1.x; the v2 packages have different names (see the update above).
| |
Basic Server Structure
| |
Configuration Files
package.json
| |
tsconfig.json
| |
Build and Run
| |
Connecting to Claude
To use your MCP server with Claude Desktop, add it to your configuration:
| |
Claude can now read the task list as a resource and create tasks through the add_task tool. Use an absolute path in args, and restart Claude Desktop after editing the file. Do not write to stdout (console.log) in a stdio server, because stdout carries the protocol messages; log to stderr.
Best Practices
Security First
Security Guidelines
| Concern | Recommendation | Priority |
|---|---|---|
| Input Validation | Validate all inputs against schemas | Critical |
| Authentication | Implement proper auth for sensitive operations | Critical |
| Audit Logging | Log all tool executions | High |
| Rate Limiting | Prevent abuse and runaway operations | High |
Performance Guidelines
| Aspect | Recommendation | Benefit |
|---|---|---|
| Caching | Cache frequently accessed resources | Lower latency |
| Pagination | Use pagination for large datasets | Memory efficiency |
| Timeouts | Implement timeouts for long operations | Reliability |
| Batching | Batch related operations | Throughput |
Error Handling
| Practice | Implementation |
|---|---|
| Clear Messages | Provide actionable error descriptions |
| Graceful Handling | Handle edge cases without crashing |
| No Leaks | Don’t expose internal system details |
| Logging | Log errors for debugging |
Integration Possibilities
| Category | Examples | Use Cases |
|---|---|---|
| Databases | PostgreSQL, MongoDB, Redis | Data access, CRUD operations |
| Business Apps | CRM, ERP, Helpdesk | Customer data, workflows |
| Dev Tools | Git, CI/CD, Issue trackers | Development automation |
| Cloud Services | AWS, GCP, Azure | Infrastructure management |
Next Steps
- Identify Use Cases: What data and actions would be valuable for AI access?
- Design Resources: Define the data structures AI should query
- Plan Tools: Determine what actions AI should execute
- Implement Security: Build proper authentication and validation
- Test Thoroughly: Verify behavior with edge cases
- Deploy & Monitor: Track usage and errors in production
Need help building MCP integrations? Contact us to discuss your requirements.
SmartTechLabs
Building Intelligent Solutions: IoT, Edge Computing, AI & LLM Integration
Related Articles
MCP - Extend and Connect
Model Context Protocol MCP is an open protocol that lets AI applications use external tools and data …
Read moreAI Agents and Skills
Agents: What Changed An agent is an LLM that runs in a loop: it decides on an action, calls a tool, …
Read moreComputer Vision
Computer Vision Solutions We build vision systems that turn camera images into events and …
Read more