mcp-server-ai-agent

No description

GitHub Stars

0

User Rating

Not Rated

Forks

0

Issues

0

Views

1

Favorites

0

README
🧠 MCP Server AI Agent

This repository implements an AI agent compatible with Model Context Protocol (MCP), enabling seamless interaction with tools exposed by an MCP-compliant server.

The agent connects to a local or remote MCP server, automatically discovers available tools, and intelligently invokes them based on user input using chain-of-thought prompting and tool planning strategies.


✨ Features
  • βœ… Tool Auto-Discovery via MCP protocol
  • 🧩 Tool Planning using natural language reasoning
  • πŸ”„ Flexible Transport Support: STDIO and HTTP/SSE
  • πŸ“¦ Modular Architecture for extensibility
  • πŸ—£οΈ LLM-Powered Responses that include tool results

πŸš€ Getting Started
1. Clone and Install
git clone https://github.com/Mehedy-Tanvir/mcp-server-ai-agent.git
cd mcp-server-ai-agent
npm install
2. Configuration

Create a .env file in the root directory with the following variables:

MCP_TRANSPORT=stdio             # or "http"
MCP_SERVER_URL=http://localhost:3000
LLM_API_KEY=your-openai-or-anthropic-key
3. Run the Agent
npm start

The agent will connect to the MCP server and start handling inputs via the selected transport.


πŸ“ Project Structure
mcp-server-ai-agent/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agent/         # Agent logic for reasoning, tool calling
β”‚   β”œβ”€β”€ transports/    # Communication layer (STDIO, HTTP/SSE)
β”‚   β”œβ”€β”€ tools/         # Tool invocation and handling
β”‚   └── main.ts        # Entry point
β”‚
β”œβ”€β”€ .env               # Configuration file
β”œβ”€β”€ package.json       # Node project metadata
└── README.md          # Project documentation

🧠 How It Works
  1. Agent connects to the MCP server and fetches the list of available tools.
  2. For each user prompt, it plans tool usage using LLM reasoning.
  3. Tools are called via MCP, and the result is injected back into the conversation.
  4. Final response is generated and returned to the user.

πŸ§ͺ Example

Prompt:

What's the weather in Dhaka?

Flow:

  • Agent finds a getWeather(city) tool
  • Calls: getWeather("Dhaka") β†’ "32Β°C, sunny"
  • Responds: "It’s currently 32Β°C and sunny in Dhaka."

πŸ“Œ Requirements
  • Node.js 18+
  • MCP server running locally or remotely
  • An LLM API key (e.g. OpenAI, Anthropic)

🀝 Contributing

Contributions, improvements, and new ideas are welcome!

Please open issues or submit pull requests with your enhancements.


πŸ“„ License

This project is licensed under the MIT License.


πŸ™Œ Credits

Created by Mehedy Tanvir

Inspired by the Anthropic MCP reference

Author Information
Md. Mehedy Hasan Tanvir

Hi, I'm a Full stack developer passionate about React, Node, Express, and MongoDB. I'm aspiring to become a senior developer in next two years.

FlowAppzMymensingh, Bangladesh

5

Followers

157

Repositories

0

Gists

3

Total Contributions

Top Contributors

Threads