MCP file server
Click on "Deploy 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 file serverList the files in the current directory and summarize what this project does"
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.
ai-agents-mcp-typescript
A minimal, readable template for building AI agents in TypeScript that use tools over the Model Context Protocol (MCP). It includes a working MCP file server, an MCP client, and a bounded agent loop. Fork it and replace the tools and the LLM provider with your own.
Features
MCP over stdio: a server (
server.ts) exposes tools, and the agent (agent.ts) connects as a client and discovers them at runtime.Explicit agent loop: Perceive, Decide, Act, Observe, Repeat. Each phase is a small, separately tested module in
phases/.Provider-agnostic LLM interface: the loop depends on an
LLMProviderinterface. An Anthropic implementation using plainfetchis included.Safe by default: the loop stops after a maximum number of iterations, and oversized tool results are truncated before they reach the model.
No build step: Node runs the TypeScript sources directly.
Tested: unit tests with Vitest sit next to the code they cover.
Related MCP server: MCP File Manager
Architecture
flowchart LR
subgraph Agent["agent.ts (MCP client)"]
P[PERCEIVE<br/>list tools] --> D[DECIDE<br/>ask the LLM]
D -->|tool calls| A[ACT<br/>call tools]
A --> O[OBSERVE<br/>append results]
O -->|repeat| D
D -->|no tool calls| R[Final answer]
end
D <-->|HTTPS| L[(Anthropic<br/>Messages API)]
P <-->|MCP over stdio| S
A <-->|MCP over stdio| S[server.ts<br/>list_files, read_files]Phase | File | Responsibility |
Perceive | List the server's MCP tools and convert them to LLM tool definitions. | |
Decide | Send the conversation and tools to the LLM and return its response. | |
Act | Execute the requested tool calls. Failures become error results instead of exceptions. | |
Observe | Append the assistant message and tool results to the history, truncating long results. | |
Repeat |
|
Requirements
Node.js 22.18 or later
pnpm 10
Quick start
pnpm install
cp .env.example .env # then set ANTHROPIC_API_KEY in .env
pnpm agent "List the files in the current directory and summarize what this project does"The prompt is the first command-line argument. Without one, the agent lists the files in the current directory. The agent starts the MCP server itself, so you do not need to run pnpm server separately.
Configuration
Setting | Where | Default |
|
| required |
|
|
|
|
|
|
|
|
|
|
|
|
Extending the template
Add a tool. Register it in server.ts with server.registerTool(name, { description, inputSchema }, handler). The agent discovers it on the next run.
Use another LLM. Implement the LLMProvider interface from llm/types.ts, which is a single chat(messages, tools) method, and pass your provider to runAgent. See llm/anthropic.ts for a reference implementation.
Use another tool backend. runAgent only needs a ToolExecutor (a callTool method), so it works with any MCP client, or with a stub in tests.
Development
pnpm test # run the Vitest suite once
pnpm typecheck # tsc --noEmit
pnpm server # run the MCP server standalone (speaks MCP on stdio).
├── agent.ts # entry point: connects to the server and runs the agent
├── server.ts # MCP file server (list_files, read_files)
├── llm/ # provider interface and Anthropic implementation
└── phases/ # perceive, decide, act, observe, repeat (with tests)Security
The
list_filesandread_filestools accept any path and can read anything the user running the agent can access. They are not restricted to a project directory.Your prompt, and the contents of any files or directories the model reads, are sent to the Anthropic API.
Run the agent only in directories that contain nothing sensitive, and restrict paths in
server.tsbefore using it with real data.Never commit your
.envfile. It is listed in.gitignore.
License
This server cannot be deployed
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
Manage files and folders directly from your workspace. Read and write files, list directories, cre…
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides LLMs with local filesystem operations (read/write files, list directories) and command execution via MCP, enabling file management and task automation within AI clients.75 npmISC
- FlicenseAqualityDmaintenanceEnables listing, reading, and searching local files and directories through MCP tools.4-
- FlicenseNot gradedqualityDmaintenanceProvides sandboxed file system tools (read, write, search, list, watch) over the Model Context Protocol, enabling resume matching and analysis workflows via an agent.-
- FlicenseNot gradedqualityBmaintenanceExposes the agent's sandboxed file tool over stdio so any MCP client can retrieve the contents of a UTF-8 text file inside the working directory, with failures returned as recoverable error strings instead of exceptions. It lets the same ReAct loop swap in-process dispatch for an MCP hop without changing tool signatures.-