mcpField
B
Building MCP Servers: Part 1 — Getting Started with Resources

Building MCP Servers: Part 1 — Getting Started with Resources

Local
github.com/cycle-sync-aiDeveloper Tools0Updated 78w ago

About Building MCP Servers: Part 1 — Getting Started with Resources

This tutorial helps MCP developers build a basic server with Node.js, TypeScript, and `@modelcontextprotocol/sdk`. It focuses on exposing read-only file, database, or API content as resources, with examples and a brief look at tools.

Key features

  1. 01Introduction to MCP resources
  2. 02Node.js and TypeScript project setup
  3. 03Read-only resources with URIs and metadata
  4. 04Documentation, log, and customer-data examples

Use cases

  1. 01Provide documentation or guides to LLMs
  2. 02Expose logs and error messages as resources
  3. 03Make customer-data summaries available to models

MCP support

The tutorial demonstrates building an MCP server with `@modelcontextprotocol/sdk` to expose read-only content to MCP clients, and briefly introduces MCP tools.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Building MCP Servers: Part 1 — Getting Started with Resources

This tutorial walks you through setting up a basic MCP (Model Context Protocol) server to expose read-only resources to Large Language Models (LLMs) like Claude. You’ll learn what MCP is, why resources are useful, and how to initialize a Node.js/TypeScript project with the @modelcontextprotocol/sdk.

Table of Contents

What is Model Context Protocol?

The Model Context Protocol (MCP) is a standardized interface that allows LLMs to safely interact with external data and services. With MCP, you can expose files, databases, APIs, and more to your AI models in a controlled manner.

What are MCP Resources?

Resources are read-only endpoints that expose content (text or binary) via a unique URI. Examples include:

  • file:///path/to/file.txt
  • database://users/123
  • api://weather/latest

Each resource has metadata like a display name and MIME type.

Why Use Resources?

Resources enable LLMs to:

  • Read files and databases
  • Execute commands
  • Access APIs
  • Interact with local tools

All interactions require explicit user permission, ensuring security and auditability.

Example Servers

Documentation Server

Expose your documentation:

docs://api/reference     → API documentation
docs://guides/getting-started  → User guides
Log Analysis Server

Serve system logs:

logs://system/today      → Today's logs
logs://errors/recent     → Recent error messages
Customer Data Server

Provide customer insights:

customers://profiles/summary   → Customer overview
customers://feedback/recent    → Latest feedback

Getting Started

Prerequisites
  • Node.js (>= 16)
  • npm (>= 8)
  • TypeScript
Installation
mkdir hello-mcp
cd hello-mcp
npm init -y
npm install @modelcontextprotocol/sdk
npm install -D typescript @types/node
Project Setup
  1. Update package.json:

    {
      "name": "hello-mcp",
      "version": "1.0.0",
      "type": "module",
      "scripts": {
        "build": "tsc",
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "dependencies": {
        "@modelcontextprotocol/sdk": "^1.1.0"
      },
      "devDependencies": {
        "typescript": "^5.7.2",
        "@types/node": "^22.10.5"
      }
    }
    
  2. Create tsconfig.json:

    {
      "compilerOptions": {
        "target": "ES2022",
        "module": "Node16",
        "moduleResolution": "Node16",
        "outDir": "./build",
        "rootDir": "./src",
        "strict": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true
      },
      "include": ["src/**/*"]
    }
    
  3. Create a src/ directory and start coding your MCP server.

Next Steps

Check out Part 2 for configuring transports and advanced features.

MCP Tools (Dynamic Actions)

MCP Tools (also called dynamic actions) let you define custom functions that the LLM can call during a session, extending MCP’s capabilities beyond static resources.

Tools vs Prompts

AspectMCP ToolsPrompts
CapabilityExecutes code & actionsStatic natural language
SecurityControlled & auditableNo external effects
FlexibilityHigh (custom logic)Limited to inference

Complete Our Greeting Server

Below is a simple example of a greeting server exposing a greeting resource:

import { ResourceServer } from "@modelcontextprotocol/sdk";

const server = new ResourceServer({ port: 3000 });

server.addResource({
  uri: "greeting://hello",
  displayName: "Greeting Resource",
  fn: async (req) => {
    const name = req.query.name || "World";
    return `Hello, ${name}!`;
  },
});

server.listen(() => console.log("Greeting server running on port 3000"));

Sources & Additional Reading

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.