This is a basic implementation of a Model Context Protocol (MCP) server using the stdio transport. It includes a simple getPassword tool that returns "foobar" as a password.
pnpm installpnpm buildThe server is designed to be run via the client:
node dist/client.jsThis will:
- Start the MCP server as a child process
- Connect a client to the server via stdio transport
- List available tools
- Call the
getPasswordtool to retrieve the password "foobar" - Call the
echotool with a message
The server implements two tools:
getPassword: Returns "foobar" as the password (no parameters)echo: Echoes back the provided message (requires amessageparameter)
When running the client, you should see output similar to:
Connecting to server...
Connected to server.
Listing available tools:
{
"tools": [
{
"name": "getPassword",
"description": "",
"arguments": []
},
{
"name": "echo",
"description": "",
"arguments": [
{
"name": "message",
"description": "",
"required": true
}
]
}
]
}
Calling getPassword tool:
Password: foobar
Calling echo tool:
Echo Response: You said: Hello from MCP client!
Closed connection to server.