MCP file server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
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.715 npmISC
- FlicenseAqualityDmaintenanceEnables listing, reading, and searching local files and directories through MCP tools.4-
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients to list, read, and write files in a local test_data directory over stdio, with path traversal protection.-
- AlicenseNot gradedqualityBmaintenanceExposes filesystem operations (read, write, list, move, delete, search), shell command execution, screenshots, mouse and keyboard control, and screen/window inspection as 15 tools plus configuration resources over stdio, SSE, or streamable HTTP. It lets MCP clients drive local computer-use and file management tasks with a fully local model stack.MIT