MCP Server with Tool, Resource, Prompt, and Sampling
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Server with Tool, Resource, Prompt, and SamplingCreate a random user"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server with Tool, Resource, Prompt, and Sampling
A full-featured Model Context Protocol (MCP) server built with Node.js and TypeScript. This project demonstrates how to implement and integrate the core capabilities of MCP into a single server, communicating over stdio.
🚀 Features
This server showcases the four main pillars of the Model Context Protocol:
Resources (
users://all): Exposes local data to the LLM. It safely reads fromsrc/data/users.jsonusingnode:fsso the LLM can analyze existing user data.Tools (
create-user): Allows the LLM to take action by securely writing new user data to the local file system with strict validation viazod.Sampling (
create-random-user): Demonstrates server-to-client LLM requests. When triggered, the server uses thesampling/createMessageendpoint to ask the client LLM to generate fake user data, parses the response, and automatically saves it.Prompts: Configured to support structured prompt templates that guide the LLM's interactions with the provided tools and resources.
Related MCP server: LocalData MCP Server
🛠️ Prerequisites
Node.js: v20 or higher (Tested on v24)
Package Manager:
yarnornpm
📦 Installation
Clone the repository and navigate to the directory:
cd mcp-server-samplingInstall dependencies:
yarn install(Ensure @modelcontextprotocol/sdk and zod are installed).
Initialize the data file: Ensure you have an empty or valid JSON array in src/data/users.json:
JSON:🏗️ Build & Run
Because this project uses modern ES Modules (ESM) and is strictly typed, you must build the project before connecting it to an MCP client like VS Code.
Compile the TypeScript code to JavaScript:
Bash yarn build (This outputs the compiled code to the /build directory).
(Optional) Test the server locally using the MCP Inspector:
npx @modelcontextprotocol/inspector node build/server.js🔌 VS Code Configuration
To connect this server to VS Code (or Cursor/Claude Desktop), you need to register it in your client's MCP settings.
For VS Code, update your configuration (usually found in your MCP settings file) to point to the compiled server.js file:
{
"mcp.servers": {
"my-mcp-server-sampling": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/build/server.js"],
"cwd": "${workspaceFolder}"
}
}
}⚠️ Important Troubleshooting Note:
Always remember to run yarn build after making any changes to src/server.ts. VS Code executes the compiled build/server.js file, so if you skip the build step, your changes will not be reflected in the IDE.
🐛 Common Pitfalls Avoided
ESM Imports: All @modelcontextprotocol/sdk imports include the .js extension to comply with strict Node.js ESM resolution.
Stdio Corruption: Uses console.error exclusively for logging to prevent corrupting the JSON-RPC stdout stream used for client-server communication.
Dynamic JSON Loading: Uses node:fs with absolute paths rather than import statements to reliably read users.json both in development (tsx) and production (node).
Available Tools
2 toolscreate-random-userA
Create a random user with fake data
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds behavioral context beyond annotations by stating data is 'random' and 'fake'. Annotations already indicate creation (readOnlyHint false) and non-idempotent, but description clarifies the nature of the generated data.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no wasted words. It efficiently conveys the tool's purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no parameters and no output schema, the description adequately states the function. However, it does not mention what the tool returns, which could be valuable for the agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters exist, so baseline is 4. The description does not need to add parameter info, and schema coverage is 100%.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses specific verb 'Create' and resource 'random user', and implies distinction from sibling 'create-user' by specifying 'random' and 'fake data'. It clearly states what the tool does.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description does not explicitly state when to use this tool versus the sibling 'create-user'. Usage is implied but not guided with when/why or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
create-userB
Create a new user
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Your name | |
| Yes | Your email address | ||
| phone | Yes | Your phone number (optional) | |
| address | No | Your address (optional) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations declare non-reonly, non-idempotent, and non-destructive behavior, which aligns with a creation operation. The description adds no further behavioral details (e.g., side effects, authorization needs), so it does not significantly enhance transparency beyond the structured annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise at four words and front-loaded with the core action. It is efficient but could benefit from additional context without being verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With four parameters, three required, and no output schema, the description lacks sufficient context. It does not explain success/error behavior, return values, or what constitutes a 'user' in this context, leaving gaps for a tool that likely has moderate complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, with all four parameters having descriptions. The description does not add any additional semantic meaning or context for the parameters beyond what is already in the schema, so baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Create a new user' clearly states a specific verb and resource. However, it does not explicitly differentiate from the sibling tool 'create-random-user', leaving it to the agent to infer that this tool creates a specific user rather than a random one.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives, such as 'create-random-user'. There is no mention of prerequisites, conditions, or exclusions, leaving the agent without context for appropriate invocation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v1.0.0- First observed
create-random-user - First observed
create-user
TDQS
Scored across 2 tools
Both tools create users, but one creates a specific user and the other creates a random one. Descriptions clearly distinguish them, though the core action is the same.
Both tools follow a consistent verb_noun snake_case pattern: create-user and create-random-user.
With only 2 tools focused solely on user creation, the count is too low for a server that also advertises resources, prompts, and sampling capabilities.
The tools only cover creation (specific and random) but lack essential user management operations like reading, updating, deleting, or listing users.
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- Era ContextOAuthapp.era
Personal finance, bank account, and shared memory connector for Claude, ChatGPT, Gemini Spark & more
Universal persistent memory and knowledge retrieval layer for AI agents and LLMs.
Give your agent live data from Twitter, Reddit, the web and GitHub. No API keys, no scraping stack.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to access and manage user profile information including name, company, location, role, interests, and skills. Supports both static configuration files and dynamic session-based storage with automatic date context.-
- AlicenseNot gradedqualityAmaintenanceGives LLM agents access to local and remote data via databases, files, graphs, and structured documents, along with a full data science toolkit for analysis and modeling.4Apache 2.0
- FlicenseAqualityBmaintenanceEnables LLMs to access a user's personal writing context—voice, style, opinions, expertise, projects, and communication patterns—via curated markdown files, helping the LLM match the user's voice when generating written content.23-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents with long-term memory and retrieval-augmented generation (RAG) capabilities, allowing them to recall past conversations, search local files, and learn user preferences.MIT