Provides keyphrase extraction capabilities for OpenAI ChatGPT through HTTP transport and OpenAI Agents SDK integration, enabling AI-driven workflows to extract relevant keyphrases from documents using BERT models
🔤 Keyphrases-MCP
Empowering LLMs with authentic keyphrase Extraction
Built with the following tools and technologies:
Overview
This Keyphrases MCP Server is a natural language interface designed for agentic applications to extract keyphrasess from provided text. It integrates seamlessly with MCP (Model Content Protocol) clients, enabling AI-driven workflows to extract keyphrases more accurately and with higher relevance using the BERT machine learning model. It works directly with your local files in the allowed directories saving the context tokens for your agentic LLM. The application exposes found keyphrases but not file's content to the MCP client.
Using this MCP Server, you can ask the following question:
"Extract 7 keyphrases from the file. [ABSOLUTE_FILE_PATH]"
"Extract 3 keyphrases from the given file ignoring the stop words. Stop words: former, due, amount, [OTHER_STOP_WORDS]. File: [ABSOLUTE_FILE_PATH]"
Keyphrases help users quickly grasp the main topics and themes of a document without reading it in full and enable the following applications:
tags or metadata for documents, improving organization and discoverability in digital libraries
emerging trends, sentiment, identified from customer reviews, social media, or news articles
features or inputs for other tasks, such as text classification, clustering
Reasoning for keyphrases-mcp
Autoregressive LLM models such as in Claude or ChatGPT process text sequentially, which—not only limits their ability to fully contextualize keyphrases across the entire document—but also suffers from context degradation as the input length increases, causing earlier keyphrases to receive diluted attention.
Bidirectional models like BERT, by considering both left and right context and maintaining more consistent attention across the sequence, generally extract existing keyphrases from texts more accurately and with higher relevance especially when no domain-specific fine-tuning is applied.
However, as autoregressive models adopt longer context windows and techniques such as input chunking, their performance in keyphrase extraction is improving, narrowing the gap with BERT. And domain-specific fine-tuning can make autoregressive LLM model to outperform the BERT solution.
This MCP server combines BERT for keyphrase extraction with an autoregressive LLM for text generation or refinement, enabling seamless text processing.
How it works
The server uses a KeyBERT framework for the multi-step extraction pipeline combining spaCy NLP preprocessing with BERT embeddings:
Candidate Generation: KeyphraseCountVectorizer identifies meaningful keyphrase candidates using spaCy's en_core_web_trf model and discarding stop words
Semantic Encoding: Candidates and document are embedded using paraphrase-multilingual-MiniLM-L12-v2 sentence transformer
Relevance Ranking: KeyBERT calculates cosine similarity between candidate keyphrase and document embeddings
Diversity Selection: Maximal Marginal Relevance (MMR) ensures diverse, non-redundant keyphrases
Final Output: Top N most relevant and diverse keyphrases are selected and sorted alphabetically
There are various pretrained embedding models
for BERT. The "paraphrase-multilingual-MiniLM-L12-v2"
for multi-lingual documents or any other language that is used by default.
You can specify "all-MiniLM-L6-v2"
model for English documents by exporting MCP_KEYPHRASES_EMBEDDINGS_MODEL
environment variable (see the src/config.py
for details).
Integration
OpenAI
Run the keyphrases-mcp server locally and expose it to the internet via ngrok
:
Note the public URL (e.g., https://your-server.ngrok.io) for the next steps.
Add to ChatGPT with the following:
Enable Developer Mode Open ChatGPT and go to Settings → Connectors Under Advanced, toggle Developer Mode to enabled
Create Connector In Settings → Connectors, click Create Enter: Name: Keyphrases-MCP Server URL: https://your-server.ngrok.io/mcp/ Check I trust this provider Click Create
Use in Chat
Start a new chat
Click the + button → More → Developer Mode Enable your MCP server connector (required - the connector must be explicitly added to each chat)
Now you can use the tool.
With Docker
You can use a dockerized deployment of this server to provide access via Streamable HTTP transport to MCP clients as follows:
Build the image, it will take ~10 GB of the disk space.
Run the container exposing ports, temporary directory to store the embeddings model, and documents directory.
OpenAI Agents SDK
Integrate this MCP Server with the OpenAI Agents SDK. Read the documents to learn more about the integration of the SDK with MCP.
Install the Python SDK.
Configure the OpenAI token:
And run the application.
You can troubleshoot your agent workflows using the OpenAI dashboard.
Claude Desktop
Run the following command once to download embedding models. Exit with Ctrl+C after you see "Done. KeyBERT runs..." log entry in the console.
Update the Claude configuration file on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
on windows: %APPDATA%\Claude\claude_desktop_config.json
Add the kyphrases-mcp server configuration to run it from pypi org with uvx
:
Start the application. It will take some time do download ~1 GB of dependencies on the first launch.
Alternatively, you can clone the source code from the GitHub repository and start the server using uv
. This is usually desired for development.
Development
Build from the source and intsall dependencies:
Run linters and tests with:
Integration testing
You can use the MCP Inspector for visual debugging of this MCP Server.
Contributing
Fork the repo
Create a new branch (
feature-branch
)Run linters and tests
Commit your changes
Push to your branch and submit a PR!
License
This project is licensed under the MIT License.
Contact
For questions or support, reach out via GitHub Issues.
This server cannot be installed
Enables AI-driven workflows to extract keyphrases more accurately and with higher relevance using the BERT machine learning model. It works directly with your local files in the allowed directories saving the context tokens for your agentic LLM.