mcp-explore

No description

GitHub Stars

0

User Rating

Not Rated

Favorites

0

Views

8

Forks

0

Issues

0

README
๐Ÿง  MCP Client + Ollama Tool Calling Prototype

.NET

Ollama Model
Platform

This project is a prototype that demonstrates how to build a C# console-based AI assistant using:

  • ๐Ÿงฐ MCP (Model Context Protocol) for local tool calling
  • ๐Ÿฆ™ Ollama as a local LLM engine
  • ๐Ÿ’ฌ Microsoft.Extensions.AI for chat orchestration and tool integration
  • โš™๏ธ ToolServer (MyFirstMCP) exposing callable functions like echo and echo_in_reverse

The assistant uses local LLMs that support tool calling (like llama3.1), and can automatically invoke functions via the MCP tool server to perform tasks.


๐Ÿš€ What It Does
  • Starts an MCP tool server (another .NET project) with local tools
  • Connects with gitmcp to get context of the current repo
  • Starts a chat session with a local model running via Ollama
  • Accepts user input from the terminal
  • LLM decides what tool to call
  • Returns tool output or a natural response via streaming

๐Ÿ› ๏ธ Tech Stack
Component Description
.NET 9 Main runtime
OllamaSharp .NET SDK for Ollama
Microsoft.Extensions.AI Experimental chat tooling for .NET
Model Context Protocol (MCP) Tool calling protocol
Ollama Local model runner with support for Mistral, LLaMA3, DeepSeek, etc

๐Ÿงช Example Terminal Session
MCP Server tools: echo, echo_in_reverse
MyFirstMCPClient started. Type 'exit' to quit.
> hello world
The response from the tool call is:

"hello from c#: hello world"

๐Ÿง  What I Learned

This repo is part of my deep-dive into understanding:

  • How to use tool calling in AI assistants via MCP
  • How LLMs can delegate tasks to local programs and format responses
  • Streaming chat and message history management
  • How Ollama supports function invocation locally
  • Try setting up a minimal production-ready LLM tool ecosystem in C#
  • Adding better context to any AI modal

๐Ÿงฉ Project Structure
mcp-explore/
โ”‚
โ”œโ”€โ”€ MyFirstMCP/                # MCP tool server (runs echo tool)
โ”‚   โ””โ”€โ”€ ...                    # Contains implementation of tools
โ”‚
โ”œโ”€โ”€ MyFirstMCPClient/          # Main console app that uses chat + tool calling
โ”‚   โ”œโ”€โ”€ Program.cs
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ README.md

๐Ÿงฌ Requirements
  • .NET 9 SDK
  • Ollama installed and running locally
  • A model pulled and ready to use (example: ollama run llama3.1)
  • Optional: VSCode or Rider for development

โš™๏ธ Run It
# 1. Start Ollama (if not already running)
ollama run llama3.1
 - also make sure the modal supports tools, such as llama3.1

# 2. Run the MCP tool server project, (you can skip this since the client will start this process)
cd MyFirstMCP
dotnet run

# 3. In another terminal, run the chat client
cd MyFirstMCPClient
dotnet run

๐Ÿงฉ Tools Implemented in MCP Server
Tool Name Description
echo Repeats the message back
reverse_echo Repeats message in reverse

More tools can be added by extending the MCP project.
such as api requsts, fetching documents etc.
If using a multimodal ai even files and images can be fetched.
Tools can also be actions such as writing to a file I assume, I will try this soon.


๐Ÿงญ Roadmap (Next Steps)
  • Add more complex tools (math, file access, time)
  • Web UI using Blazor or Minimal API
  • Tool selection controls (manual/auto mode)
  • Persist conversation history
  • Experiment with ToolMode.AnyRequired vs Auto

๐Ÿ“œ License

MIT โ€” you're free to use, modify, and extend.


๐Ÿ™‹โ€โ™‚๏ธ Maintained by

Naser Al-Asbahi
Developer & student exploring full-stack dev, AI, Arabic language & Islamic thought.

"Learning by building. Understanding by breaking."