Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Creating Simple MCP Server | Setting Up and Configuration
Creating Custom AI Agents
course content

Conteúdo do Curso

Creating Custom AI Agents

Creating Custom AI Agents

1. Agentic AI Basics
2. Setting Up and Configuration

book
Creating Simple MCP Server

VIDEO

You'll build a minimal Model Context Protocol (MCP) server using Python. The server will read data from an Excel file and return it in JSON format. This type of setup allows tools like Claude Desktop or any MCP-compatible client to trigger external logic—like reading a spreadsheet—by sending structured JSON requests. Your goal is to create a Flask-based HTTP endpoint that:

  • Accepts a file and sheet name via JSON;

  • Loads the specified Excel sheet;

  • Returns the first 5 rows in a JSON response.

This structure allows AI to interact with your logic through a clean interface, using context to decide which function to call and what data to request. Start by importing the required libraries and initializing the Flask app:

file1

copy

Next, define a route that listens for POST requests. This route reads the Excel file and sheet specified in the request body.

file1

copy
  • Reads the incoming JSON request with request.get_json();

  • Looks for "file" and "sheet" keys. If "sheet" isn’t provided, it defaults to the first sheet;

  • Opens the Excel file using load_workbook;

  • Reads up to 5 rows using iter_rows(values_only=True) and converts them into a list of lists;

  • Returns the rows as a JSON response.

Finally, add the code that starts the Flask server:

file1

copy

Run this script. The server will be available at http://localhost:5000/read_excel.

file1

copy

This server acts as a basic MCP-compatible tool. When connected to Claude Desktop or any AI agent that understands MCP, your endpoint can be triggered by natural language like:

Claude (or another model) will format a JSON request, send it to your server, and use the returned data in its reply. You're not just building an API you're enabling structured, AI-friendly tooling that bridges natural language and local logic.

question mark

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2

Pergunte à IA

expand
ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

course content

Conteúdo do Curso

Creating Custom AI Agents

Creating Custom AI Agents

1. Agentic AI Basics
2. Setting Up and Configuration

book
Creating Simple MCP Server

VIDEO

You'll build a minimal Model Context Protocol (MCP) server using Python. The server will read data from an Excel file and return it in JSON format. This type of setup allows tools like Claude Desktop or any MCP-compatible client to trigger external logic—like reading a spreadsheet—by sending structured JSON requests. Your goal is to create a Flask-based HTTP endpoint that:

  • Accepts a file and sheet name via JSON;

  • Loads the specified Excel sheet;

  • Returns the first 5 rows in a JSON response.

This structure allows AI to interact with your logic through a clean interface, using context to decide which function to call and what data to request. Start by importing the required libraries and initializing the Flask app:

file1

copy

Next, define a route that listens for POST requests. This route reads the Excel file and sheet specified in the request body.

file1

copy
  • Reads the incoming JSON request with request.get_json();

  • Looks for "file" and "sheet" keys. If "sheet" isn’t provided, it defaults to the first sheet;

  • Opens the Excel file using load_workbook;

  • Reads up to 5 rows using iter_rows(values_only=True) and converts them into a list of lists;

  • Returns the rows as a JSON response.

Finally, add the code that starts the Flask server:

file1

copy

Run this script. The server will be available at http://localhost:5000/read_excel.

file1

copy

This server acts as a basic MCP-compatible tool. When connected to Claude Desktop or any AI agent that understands MCP, your endpoint can be triggered by natural language like:

Claude (or another model) will format a JSON request, send it to your server, and use the returned data in its reply. You're not just building an API you're enabling structured, AI-friendly tooling that bridges natural language and local logic.

question mark

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt