MarkItDown MCP Can Convert Any Doc into Markdowns!

Dealing with paperwork is now not nearly opening recordsdata in your AI initiatives, it’s about reworking chaos into readability. Docs equivalent to PDFs, PowerPoints, and Phrase flood our workflows in each form and dimension. Retrieving structured content material from these paperwork has grow to be a giant job at this time. Markitdown MCP (Markdown Conversion Protocol) from Microsoft simplifies this. It converts varied recordsdata into structured Markdown format. This helps builders and technical writers enhance documentation workflows. This text explains Markitdown MCP and reveals its utilization. We’ll cowl organising the Markitdown MCP server and also will talk about MarkItDown within the context of this protocol. Utilizing the Markitdown mcp server for testing can also be coated under.

What’s MarkItDown MCP?

Markitdown MCP gives a regular methodology for doc conversion. It acts as a server-side protocol. It makes use of Microsoft’s MarkItdown library within the backend. The server hosts a RESTful API. Customers ship paperwork like PDFs or Phrase recordsdata to this server. The server then processes these recordsdata. It makes use of superior parsing and particular formatting guidelines. The output is Markdown textual content that retains the unique doc construction.

Key Options of Markitdown MCP

The Markitdown MCP server contains a number of helpful options:

  • Broad Format Help: It converts frequent recordsdata like PDF, DOCX, and PPTX to Markdown.
  • Construction Preservation: It makes use of strategies to grasp and preserve doc layouts like headings and lists.
  • Configurable Output: Customers can modify settings to manage the ultimate Markdown fashion.
  • Server Operation: It runs as a server course of. This permits integration into automated programs and cloud setups.

The Function of Markdown in Workflows

Markdown is a well-liked format for documentation. Its easy syntax makes it straightforward to learn and write. Many platforms like GitHub assist it nicely. Static website turbines usually use it. Changing different codecs to Markdown manually takes time. Markitdown MCP automates this conversion. This offers clear advantages:

  • Environment friendly Content material Dealing with: Remodel supply paperwork into usable Markdown.
  • Constant Collaboration: Normal format helps groups work collectively on paperwork.
  • Course of Automation: Embody doc conversion inside bigger automated workflows.

Setting Up the Markitdown MCP Server for Integration

We will arrange the Markitdown MCP server with totally different purchasers like Claude, Windsurf, Cursor utilizing Docker Picture as talked about within the Github Repo. However right here we shall be creating an area MCP shopper utilizing LangChain’s MCP Adaptors. We’d like a working the server to make use of it with LangChain. The server helps totally different working modes.

Set up

First, set up the required Python packages.

pip set up markitdown-mcp langchain langchain_mcp_adapters langgraph langchain_groq

Server Configuration

Run the Markitdown MCP server utilizing STDIO mode. This mode connects commonplace enter and output streams. It really works nicely for script-based integration. Straight run the next within the terminal.

markitdown-mcp

The server will begin working with some warnings.

MarkItDown MCP Can Convert Any Doc into Markdowns!

We will additionally use SSE (Server-Despatched Occasions) mode. This mode fits net purposes or long-running connections. Additionally it is helpful when organising a Markitdown MCP server for testing particular situations.

markitdown-mcp --sse --host 127.0.0.1 --port 3001

Choose the mode that matches your integration plan. Utilizing the the server for testing regionally by way of STDIO is usually a great begin. We suggest utilizing STDIO mode for this text.

Markdown Conversion with Markitdown MCP

We have now already coated find out how to construct an MCP server and shopper setup regionally utilizing LangChain in our earlier weblog MCP Shopper Server Utilizing LangChain.

Now, this part reveals find out how to use LangChain with the Markitdown MCP server. It automates the conversion of a PDF file to Markdown. The instance employs Groq’s LLaMA mannequin by means of ChatGroq. Be certain that to arrange the Groq API key as an surroundings variable or move it on to ChatGroq.

Step 1: Import the required libraries first.

from mcp import ClientSession, StdioServerParameters
from mcp.shopper.stdio import stdio_client
from langchain_mcp_adapters.instruments import load_mcp_tools
from langgraph.prebuilt import create_react_agent
import asyncio
from langchain_groq import ChatGroq

Step 2: Initialize the Groq LLM, it’s freed from value. Yow will discover the API key right here

Right here’s the Groq API Key: Groq API Key

# Initialize Groq mannequin
mannequin = ChatGroq(mannequin="meta-llama/llama-4-scout-17b-16e-instruct", api_key="YOUR_API_KEY")

Step 3: Configure the MCP server

We’re utilizing StdioServerParameters, and straight utilizing the put in Markitdown MCP bundle right here

server_params = StdioServerParameters(
   command="markitdown-mcp",
   args=[]  # No extra arguments wanted for STDIO mode
)

Step 4: Now, outline the Asynchronous operate

This can take the PDF path because the enter, ClientSession begins communication. load_mcp_tools offers capabilities for LangChain interplay with Markitdown MCP. Then a ReAct agent is created, It makes use of the mannequin and the MCP instruments. The code creates a file_uri for the PDF and sends a immediate asking the agent to transform the file utilizing MCP.

async def run_conversion(pdf_path: str):
   async with stdio_client(server_params) as (learn, write):
       async with ClientSession(learn, write) as session:

           await session.initialize()
           print("MCP Session Initialized.")

           # Load obtainable instruments
           instruments = await load_mcp_tools(session)
           print(f"Loaded Instruments: {[tool.name for tool in tools]}")

           # Create ReAct agent
           agent = create_react_agent(mannequin, instruments)
           print("ReAct Agent Created.")

           # Put together file URI (convert native path to file:// URI)
           file_uri = f"file://{pdf_path}"
           # Invoke agent with conversion request
           response = await agent.ainvoke({

               "messages": [("user", f"Convert {file_uri} to markdown using Markitdown MCP just return the output from MCP server")]

           })

           # Return the final message content material
           return response["messages"][-1].content material

Step 5: This code calls the run_conversion operate

We’re calling and extracting Markdown from the response. It saves the content material to pdf.md, and eventually prints the output within the terminal.

if __name__ == "__main__":

   pdf_path = "/residence/harsh/Downloads/LLM Analysis.pptx.pdf"  # Use absolute path
   end result = asyncio.run(run_conversion(pdf_path))

   with open("pdf.md", 'w') as f:
      f.write(end result)

   print("nMarkdown Conversion Consequence:")
   print(end result)

Output

Output

Full Code

from mcp import ClientSession, StdioServerParameters
from mcp.shopper.stdio import stdio_client

from langchain_mcp_adapters.instruments import load_mcp_tools
from langgraph.prebuilt import create_react_agent

import asyncio
from langchain_groq import ChatGroq
# Initialize Groq mannequin
mannequin = ChatGroq(mannequin="meta-llama/llama-4-scout-17b-16e-instruct", api_key="")
# Configure MCP server
server_params = StdioServerParameters(

   command="markitdown-mcp", 
   args=[]  # No extra arguments wanted for STDIO mode

)

async def run_conversion(pdf_path: str):
   async with stdio_client(server_params) as (learn, write):

       async with ClientSession(learn, write) as session:
           await session.initialize()

           print("MCP Session Initialized.")
           # Load obtainable instruments
           instruments = await load_mcp_tools(session)

           print(f"Loaded Instruments: {[tool.name for tool in tools]}")
           # Create ReAct agent

           agent = create_react_agent(mannequin, instruments)
           print("ReAct Agent Created.")

           # Put together file URI (convert native path to file:// URI)

           file_uri = f"file://{pdf_path}"
           # Invoke agent with conversion request
           response = await agent.ainvoke({

               "messages": [("user", f"Convert {file_uri} to markdown using Markitdown MCP just retrun the output from MCP server")]

           })

           # Return the final message content material
           return response["messages"][-1].content material

if __name__ == "__main__":
   pdf_path = "/residence/harsh/Downloads/LLM Analysis.pdf"  # Use absolute path

   end result = asyncio.run(run_conversion(pdf_path))
   with open("pdf.md", 'w') as f:

       f.write(end result)
   print("nMarkdown Conversion Consequence:")
   print(end result)

Inspecting the Output

The script generates a pdf.md file. This file holds the Markdown model of the enter PDF. The conversion high quality is dependent upon the unique doc’s construction. Markitdown MCP often preserves parts like:

  • Headings (varied ranges)
  • Paragraph textual content
  • Lists (bulleted and numbered)
  • Tables (transformed to Markdown syntax)
  • Code blocks

Output

Output

Right here within the output, we will see that it efficiently retrieved the headings, contents, in addition to regular textual content in markdown format.

Therefore, working an area server for testing helps consider totally different doc sorts.

Additionally watch:

Sensible Use Circumstances in LLM Pipelines

Integrating Markitdown MCP can enhance a number of AI workflows:

  • Information Base Constructing: Convert paperwork into Markdown. Ingest this content material into information bases or RAG programs.
  • LLM Content material Preparation: Remodel supply recordsdata into Markdown. Put together constant enter for LLM summarization or evaluation duties.
  • Doc Information Extraction: Convert paperwork with tables into Markdown. This simplifies parsing structured information.
  • Documentation Automation: Generate technical manuals. Convert supply recordsdata like Phrase paperwork into Markdown for static website turbines.

Conclusion

Markitdown MCP offers a succesful, server-based methodology for doc conversion. It handles a number of codecs. It produces structured Markdown output. Integrating it with LLMs allows automation of doc processing duties. This method helps scalable documentation practices. Utilizing the the server for testing makes analysis easy. MarkItDown’s MCP is greatest understood by means of its sensible software in these workflows.

Discover the Markitdown MCP GitHub repository for extra info.

Continuously Requested Questions

Q1. What’s the predominant operate of Markitdown MCP?

Ans. Markitdown MCP converts paperwork like PDFs and Phrase recordsdata into structured Markdown. It makes use of a server-based protocol for this job.

Q2. Which file codecs can the Markitdown MCP server course of?

Ans. The server handles PDF, DOCX, PPTX, and HTML recordsdata. Different codecs could also be supported relying on the core library.

Q3. How does LangChain use Markitdown MCP?

Ans. LangChain makes use of particular instruments to speak with the server. Brokers can then request doc conversions by means of this server.

This fall. Is Markitdown MCP open supply?

Ans. Sure, it’s open-source software program from Microsoft. Customers are chargeable for any server internet hosting prices.

Q5. Can I run the Markitdown MCP server for testing functions?

Ans. Sure, the server for testing can run regionally. Use both STDIO or SSE mode for growth and analysis.

Hello, I’m Pankaj Singh Negi – Senior Content material Editor | Obsessed with storytelling and crafting compelling narratives that remodel concepts into impactful content material. I really like studying about expertise revolutionizing our life-style.

Login to proceed studying and revel in expert-curated content material.