Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.This article provides a hands-on, step-by-step walkthrough to build a simple example on your local development machine that integrates the Unstructured API with the Python SDK for Model Context Protocol. Specifically, this walkthrough demonstrates how to write and run Python code to create an MCP server (a lightweight program that exposes specific capabilities through MCP); this MCP server uses the Unstructured Workflow Endpoint to list all of your available source connectors and to get information about a specific source connector. The Workflow Endpoint offers a full range of partitioning, chunking, embedding, and enrichment options for your files and data.
uv
, as follows.By using pip
:uv
, see the uv documentation.)mcp-unstructured-demo
. Then go to the project directory:deactivate
command:workflow.py
.
Then add the following code to this new workflow.py
file:.env
.
Then add the following code to this new .env
file, replacing <your-unstructured-api-key>
with your Unstructured API key:claude_desktop_config.json
file, and then save the file.In this file:"workflow"
must match the value that you set in mcp = FastMCP("workflow" ...
in the workflow.py
file.uv
must be the absolute path to the uv
executable on your local machine.mcp-unstructured-demo
must match the name of the project directory that you created."workflow.py"
must match the name of the Python file that you created for the MCP server.S3
with the type of source connector that you want to list.
For a list of available source connector types, see the Workflow Endpoint Sources overview.<source-connector-id>
with one of the source connector IDs that
Claude for Desktop returned in the previous step. For example:.env
. Then copy the contents of the repository’s
.env.template
file into the .env
file that you just created.As an MCP security best practice, sensitive information such as API keys should be stored in environment variables or a
secrets manager, not hard-coded in MCP server code or retrieved from the user by an MCP client.
The .env
file is a common way to store environment variables in Python projects outside of MCP server code and not
visible to MCP clients.Having your own .env
file helps ensure that you do
not accidentally commit any sensitive information from this cloned repository into other repositories (as .env
is an
entry in this cloned repository’s .gitignore
file, but .env.template
is not).In your .env
file, replace <key-here>
in the following line with your Unstructured API key:.env
file with your own values. For example, if you want to
create an Amazon S3 source or destination connector, you should provide your AWS credentials in the .env
file by specifying values
for the AWS_KEY
and AWS_SECRET
variables. For more information, see the usage comments in the original .env.template
file or in the content that you copied into your .env
file.The original .env.template
file will be updated as more features are added to the repository. You should periodically
pull down the source repository’s contents into your cloned repository to get any new features, as well as the latest version
of the .env.template
file that you can copy any newly available required environment variable names over into your existing .env
file.deactivate
command:claude_desktop_config.json
file with the following content, and then save the file.For macOS or Linux:List all available source connectors of type <source-connector-type>.
Provide information about the source connector with ID <source-connector-id>.
List all available source connectors of type <destination-connector-type>.
Provide information about the source connector with ID <destination-connector-id>.
List all available destination connectors of type <destination-connector-type>.
Provide information about the destination connector with ID <destination-connector-id>.
Create a new workflow.
Provide information about the workflow with ID <workflow-id>.
Run the workflow with ID <workflow-id>.
Update the workflow with ID <workflow-id>.
List all available workflows.
Delete the worklow with ID <workflow-id>.