It is hard to "accept" that the AI Agent works. It works. If one drops the engineering hat, it is easy to say "of course it works, give it enough information and tools, it does jobs like human." With engineering hat, there are questions of "HOW": How does it know what to do? which tools to call, which APIs to call on which conditions?
Claude Desktop is an "AI Host" agent (I called it that way, not necessarily true). It does so many amazing things. From consumer perspective, it looks like ChatGPT where users ask questions, it responds. Users can ask questions and expect specific format (JSON, table, mermaid diagram, ...) in response. It works magically.
MCP (Model Context Protocol) is the next big thing. I did some PoC with SQL server. It blew my mind. Following the sample from C# SDK and MCP sites, I have a small piece of code that allows Claude Desktop to use my new external tool, let's call it "SqlTool".
Claude Desktop is an "AI Host" agent (I called it that way, not necessarily true). It does so many amazing things. From consumer perspective, it looks like ChatGPT where users ask questions, it responds. Users can ask questions and expect specific format (JSON, table, mermaid diagram, ...) in response. It works magically.
MCP (Model Context Protocol) is the next big thing. I did some PoC with SQL server. It blew my mind. Following the sample from C# SDK and MCP sites, I have a small piece of code that allows Claude Desktop to use my new external tool, let's call it "SqlTool".
[McpServerTool, Description("Execute a SQL query and return the result as a list of dictionaries, where key is the column name, value is the row's value.")] public static async Task<string> Query(string query) { return await ExecuteQuery(query); } private static async Task<string> ExecuteQuery(string query) { try { using (var conn = new SqlConnection(ConnectionString)) { await conn.OpenAsync(); var command = new SqlCommand(query, conn); using (var adapter = new SqlDataAdapter()) { adapter.SelectCommand = command; var dataTable = new DataTable(); adapter.Fill(dataTable); var rows = new List<Dictionary<string, object>>(); foreach (DataRow row in dataTable.Rows) { var dict = new Dictionary<string, object>(); foreach (DataColumn column in dataTable.Columns) { dict[column.ColumnName] = row[column] == DBNull.Value ? null : row[column]; } rows.Add(dict); } return JsonSerializer.Serialize(rows); } } } catch (Exception ex) { // Follow the MCP protocol for error handling return JsonSerializer.Serialize(new { error = ex.ToString() }); } }
And you can ask all kinds of questions about the underlying database.
Example:
- What is the schema of table "User"?
- How many users are there in the company XYZ?
Think of common queries that you use to extract data from the database. Without AI, you need to write your own queries and execute. You need to understand table schema, the relationship.
However, the above tool is also dangerous. It is too general and AI Agent needs to execute many queries with Try-and-Error to accomplish user requested tasks.
To improve, we can provide more specific tools. For example, GetUser(userName), GetTableSchema(tableName). With a more specific description, AI Agent will pick up a better tool before going to the general Query tool. Here, we are trying to increase the chance of picking the right tool. There is no guarantee.
Another problem is that a bad query can kill the database. We do not control the execution plan. Model does. Of course, in PoC, we do not deal with potential risk.
Ok, so where is the "hard to accept" part? The planning part, the ability of model to plan for execution, and then next execution them. It also reflects and picks another strategy when the first execution plan did not accomplish the task. It works like our brain. We kind of know what to do, what to do next automatically. Of course, not entirely true, human needs training, experiment with trial and error. Now the computer does that.
Let's focus a bit on the technical side of MCP with Claude Desktop. Developers extend AI Agent with tools in form of MCP server. An MCP server can serve many tools. Note that too many tools is not good. There is an art in designing the number of tools. The "Description" of the tool and its parameters are essential. Think of them as marketing of the tools to AI Agent. If the marketing is good, the tool is picked for the right job.
Each AI Agent host connects to one or more LLM models for reasoning, generating plans, executing plans. If a model is powerful enough, it can do all. Host connects to a set of tools (via MCP Servers) to extend the information retrieval as well as executing actions.
Exciting time ahead. The benefits is unlimited so the challenges.