Skip to main content
Glama

MCP Server — AI Tool Server

Educational project demonstrating how an AI can connect to a server to execute real actions on an operating system.


What is this project?

This project simulates an MCP Server (Model Context Protocol Server) — an HTTP server that exposes tools that an Artificial Intelligence can call remotely.

The core idea is simple: the AI does not execute commands on the operating system directly. Instead, it sends an HTTP request to this server asking for a tool to be executed. The server receives it, executes it, and returns the result.

IA  →  POST /tool { "tool": "get_ip" }  →  MCP Server  →  Sistema Operacional
IA  ←  { "success": true, "result": { "ips": [...] } }  ←  MCP Server

Related MCP server: Shell Server

Project objective

  • Demonstrate client-server architecture applied to AI

  • Show how tools can be dynamically registered and selected

  • Serve as a learning base for larger projects

  • Be easy to understand, modify, and present


Stack used

Technology

Usage

Node.js

JavaScript Runtime

Express.js

HTTP Framework

fs, os, path

Native Node modules

child_process

System command execution


Folder structure

mcp-server/
│
├── src/
│   ├── server.js              ← Ponto de entrada — inicia o servidor
│   ├── routes/
│   │   └── tools.routes.js    ← Define as rotas HTTP
│   ├── controllers/
│   │   └── tools.controller.js ← Valida o input e chama o serviço
│   ├── services/
│   │   └── tools.service.js   ← Registry de tools + lógica de seleção
│   ├── tools/
│   │   ├── getIp.js           ← Tool: retorna o IP da máquina
│   │   ├── getHostname.js     ← Tool: retorna o hostname
│   │   ├── listFiles.js       ← Tool: lista arquivos de um diretório
│   │   ├── createFile.js      ← Tool: cria um arquivo
│   │   └── pingHost.js        ← Tool: faz ping em um host
│   └── utils/
│       └── response.js        ← Padroniza respostas JSON
│
├── docs/
│   ├── README.md              ← Este arquivo
│   └── AI_CONTEXT.md          ← Contexto arquitetural para IAs
│
├── package.json
└── .gitignore

How to install

Prerequisite: Node.js installed (version 18 or higher recommended).

# Clone ou copie o projeto para sua máquina
cd mcp-server

# Instale as dependências
npm install

How to run

# Modo normal
npm start

# Modo desenvolvimento (reinicia ao salvar arquivos — Node 18+)
npm run dev

The server will start on port 3000 by default.

To use a different port:

PORT=8080 npm start

How to verify it is working

Access via browser or curl:

curl http://localhost:3000/health

Expected response:

{ "status": "ok", "message": "MCP Server rodando" }

How to use — API

There are two main endpoints: one to list tools and another to execute them.

List available tools

Returns all tools registered on the server with their complete schemas (description and parameters). This format facilitates integration with AIs (Tool Calling).

GET http://localhost:3000/tools

Response:

{
  "success": true,
  "result": [
    {
      "name": "create_file",
      "description": "Cria um arquivo dentro da pasta /files.",
      "parameters": {
        "type": "object",
        "properties": {
          "filename": { "type": "string", "description": "..." },
          "content": { "type": "string", "description": "..." }
        },
        "required": ["filename"]
      }
    }
  ]
}

Execute a tool

POST http://localhost:3000/tool
Content-Type: application/json

Request format

{
  "tool": "nome_da_tool",
  "args": {
    "parametro": "valor"
  }
}

Available Tools

get_ip

Returns the machine's local IPs.

Request:

{ "tool": "get_ip", "args": {} }

get_hostname

Returns the machine's hostname, platform, and architecture.

Request:

{ "tool": "get_hostname", "args": {} }

list_files

Lists files and directories in a path. If path is omitted, it uses the current process directory.

Request:

{ "tool": "list_files", "args": { "path": "/home/user" } }

create_file

Creates a file inside the /files folder at the server root. This folder acts as a sandbox to organize generated files.

Request:

{
  "tool": "create_file",
  "args": {
    "filename": "teste.txt",
    "content": "Olá, MCP!"
  }
}

ping_host

Pings a host or IP and returns the result. Security: Only alphanumeric characters, dots, and hyphens are allowed in the host to prevent command injection.

Request:

{ "tool": "ping_host", "args": { "host": "8.8.8.8" } }

Testing with curl

# get_ip
curl -X POST http://localhost:3000/tool \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_ip", "args": {}}'

# list_files
curl -X POST http://localhost:3000/tool \
  -H "Content-Type: application/json" \
  -d '{"tool": "list_files", "args": {"path": "/tmp"}}'

# create_file
curl -X POST http://localhost:3000/tool \
  -H "Content-Type: application/json" \
  -d '{"tool": "create_file", "args": {"filename": "ola.txt", "content": "Olá mundo!"}}'

# ping_host
curl -X POST http://localhost:3000/tool \
  -H "Content-Type: application/json" \
  -d '{"tool": "ping_host", "args": {"host": "8.8.8.8"}}'

Full flow — AI → MCP → System

1. IA decide que precisa saber o IP da máquina
2. IA envia: POST /tool { "tool": "get_ip", "args": {} }
3. Express recebe a requisição
4. Route encaminha para o Controller
5. Controller valida o body e chama o Service
6. Service consulta o Registry e encontra a função getIp
7. getIp() usa o módulo "os" para ler as interfaces de rede
8. Resultado sobe de volta: getIp → Service → Controller → Response
9. IA recebe: { "success": true, "result": { "ips": [...] } }
10. IA usa o resultado para continuar sua tarefa

Possible future improvements

  • Add authentication via API Key

  • Implement call logging (who called which tool and when)

  • Add WebSocket support for streaming results

  • Integrate with local AI models (Ollama, LM Studio)

  • Add new tools: CPU/memory reading, script execution, etc.

  • Create an example client that simulates an AI calling the tools


Security notes

This project is educational. For production use, it would be necessary to:

  • Implement route authentication

  • Whitelist paths for list_files and create_file

  • Rate limiting

  • More robust input sanitization

  • HTTPS


Project developed for academic and demonstration purposes.

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A self-hosted MCP server that gives AI agents controlled access to a machine: filesystem, shell, background processes, git, web fetching and persistent key-value memory.
    GPL 3.0

View all related MCP servers

Related MCP Connectors

  • An MCP server that gives your AI access to the source code and docs of all public github repos

  • Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gagocode/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server