AI-ChatAgent-With-MCP
AI-ChatAgent-With-MCPは、C#で開発されたAIチャットエージェントで、ユーザーとの対話を自動化します。高い精度で質問に答え、情報を提供することができます。APIを通じて他のシステムと連携可能で、さまざまな業務フローの効率化に寄与します。
GitHubスター
2
ユーザー評価
未評価
お気に入り
0
閲覧数
17
フォーク
0
イシュー
0
ChatAgent with Model Context Protocol (MCP)
A .NET-based chat agent implementation that uses OpenAI's models and Model Context Protocol (MCP) for extensible tool integration. This project demonstrates how to create an AI-powered chat agent with custom tool capabilities.
Project Structure
The solution consists of two main projects:
- ChatAgent: The main application that implements the chat interface using OpenAI and MCP client.
- MCP.Server: A Model Context Protocol server that provides tools for the chat agent.
Prerequisites
- .NET 9.0
- Visual Studio 2022 or later
- OpenAI API access
Configuration
- Configure your AI settings in
appsettings.json:
{
"AI": {
"ModelId": "YOUR-MODEL",
"APIKey": "YOUR-KEY",
"Endpoint": "YOUR-ENDPOINT"
},
"MCPServers": "PATH-TO-MCP-SERVER"
}
Replace the placeholders with your actual values:
ModelId: Your OpenAI model ID (e.g., "gpt-4", "gpt-3.5-turbo")APIKey: Your OpenAI API keyEndpoint: Your OpenAI API endpoint (usually "https://api.openai.com")MCPServers: Path to the MCP.Server executable (semicolon-separated for multiple servers)
Features
- Interactive chat interface with AI-powered responses
- Integration with Model Context Protocol (MCP) for extensible tools
- Custom tool implementation example (UserTool) that fetches user data
- Support for multiple MCP servers
- Environment-specific configuration support
- Streaming chat responses for better user experience
Technologies Used
- Microsoft.SemanticKernel for AI integration
- Model Context Protocol (MCP) for tool integration
- OpenAI API for chat completion
- .NET 9.0 features
- Microsoft.Extensions.Configuration for configuration management
Getting Started
- Clone the repository
- Build the solution
- Configure your
appsettings.jsonwith appropriate AI credentials - Run the MCP.Server project
- Run the ChatAgent project
Usage
- Start the application
- Type your messages in the console
- Use 'EXIT' to end the chat session
- The agent will respond using both its AI capabilities and available MCP tools
Tool Integration
The project includes a sample tool (UserTool) that demonstrates how to integrate external functionality:
[McpServerToolType]
public class UserTool
{
[McpServerTool, Description("Tüm kullanıcıları, bilgileriyle birlikte getirir.")]
public async Task<List<object>> GetUsersAsync()
{
// Implementation
}
}
You can add more tools by creating new classes with the [McpServerToolType] attribute and methods with [McpServerTool] attribute.
Development
- Use
appsettings.Development.jsonfor development-specific settings - The project supports environment-specific configurations through
DOTNET_ENVIRONMENTvariable - Tool development should follow the MCP protocol specifications
Contributing
Feel free to contribute to this project by:
- Forking the repository
- Creating a feature branch
- Submitting a pull request