HomeBig DataMarkItDown MCP Can Convert Any Doc into Markdowns!

MarkItDown MCP Can Convert Any Doc into Markdowns!


Dealing with paperwork is not nearly opening information in your AI initiatives, it’s about remodeling chaos into readability. Docs corresponding to PDFs, PowerPoints, and Phrase flood our workflows in each form and dimension. Retrieving structured content material from these paperwork has change into a giant process as we speak. Markitdown MCP (Markdown Conversion Protocol) from Microsoft simplifies this. It converts numerous information into structured Markdown format. This helps builders and technical writers enhance documentation workflows. This text explains Markitdown MCP and exhibits its utilization. We’ll cowl establishing the Markitdown MCP server and also will focus on MarkItDown within the context of this protocol. Utilizing the Markitdown mcp server for testing can also be coated beneath.

What’s MarkItDown MCP?

Markitdown MCP affords a typical 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 information to this server. The server then processes these information. 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 consists of a number of helpful options:

  • Huge Format Assist: It converts frequent information 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 alter settings to manage the ultimate Markdown type.
  • Server Operation: It runs as a server course of. This enables integration into automated programs and cloud setups.

The Position 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 properly. Static web site turbines typically 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: Embrace doc conversion inside bigger automated workflows.

Setting Up the Markitdown MCP Server for Integration

We are able to 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 might be creating a neighborhood MCP consumer utilizing LangChain’s MCP Adaptors. We want 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 normal enter and output streams. It really works properly 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 are able to additionally use SSE (Server-Despatched Occasions) mode. This mode fits internet functions or long-running connections. It’s also helpful when establishing a Markitdown MCP server for testing particular eventualities.

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

Choose the mode that matches your integration plan. Utilizing the the server for testing domestically by way of STDIO is usually an excellent begin. We advocate utilizing STDIO mode for this text.

Markdown Conversion with Markitdown MCP

We’ve already coated the best way to construct an MCP server and consumer setup domestically utilizing LangChain in our earlier weblog MCP Consumer Server Utilizing LangChain.

Now, this part exhibits the best way 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 via ChatGroq. Be sure that to arrange the Groq API key as an setting variable or go it on to ChatGroq.

Step 1: Import the required libraries first.

from mcp import ClientSession, StdioServerParameters
from mcp.consumer.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. You could find 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 immediately utilizing the put in Markitdown MCP package deal right here

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

Step 4: Now, outline the Asynchronous operate

This may take the PDF path because the enter, ClientSession begins communication. load_mcp_tools offers features 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 out there 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 at last 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 End result:")
   print(end result)

Output

Output

Full Code

from mcp import ClientSession, StdioServerParameters
from mcp.consumer.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 out there 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 End result:")
   print(end result)

Analyzing 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 normally preserves components like:

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

Output

Output

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

Therefore, working a neighborhood server for testing helps consider totally different doc sorts.

Additionally watch:

Sensible Use Instances 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 data bases or RAG programs.
  • LLM Content material Preparation: Remodel supply information into Markdown. Put together constant enter for LLM summarization or evaluation duties.
  • Doc Knowledge Extraction: Convert paperwork with tables into Markdown. This simplifies parsing structured information.
  • Documentation Automation: Generate technical manuals. Convert supply information like Phrase paperwork into Markdown for static web site 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 finest understood via its sensible software in these workflows.

Discover the Markitdown MCP GitHub repository for extra data.

Steadily Requested Questions

Q1. What’s the most important operate of Markitdown MCP?

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

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

Ans. The server handles PDF, DOCX, PPTX, and HTML information. 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 via this server.

This autumn. Is Markitdown MCP open supply?

Ans. Sure, it’s open-source software program from Microsoft. Customers are answerable 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 domestically. Use both STDIO or SSE mode for improvement and analysis.

Hello, I’m Pankaj Singh Negi – Senior Content material Editor | Enthusiastic about storytelling and crafting compelling narratives that rework concepts into impactful content material. I like studying about know-how revolutionizing our life-style.

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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments