MarkLogic MCP Server
A Python-based MCP (Model-Controller-Processor) server for MarkLogic database operations. This server provides CRUD operations and search functionality for MarkLogic documents through a standardized interface using the MarkLogic REST API.
Features
- Document CRUD operations (Create, Read, Update, Delete)
- Document search with string and structured queries
- Collection management
- Database information retrieval
- TOML-based configuration
- Comprehensive logging
- Full REST API support
Prerequisites
- Python 3.7+
- MarkLogic Server (installed and running)
- Access to a MarkLogic database with appropriate permissions
- REST API instance configured on MarkLogic server
Installation
- Clone the repository:
git clone https://github.com/yourusername/marklogic-mcp.git
cd marklogic-mcp
- Install dependencies:
pip install -r requirements.txt
- Configure your server:
cp pyproject.toml.example pyproject.toml
Edit the pyproject.toml file with your MarkLogic connection details:
[tool.marklogic]
host = "localhost"
port = 8000
user = "your-username"
password = "your-password"
[tool.marklogic.logging]
level = "INFO"
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
Usage
- Start the MCP server:
python marklogic_mcp_server.py
- The server provides the following operations:
Create Document
create_document(uri: str, content: dict, collections: list = None)
Read Document
read_document(uri: str)
Update Document
update_document(uri: str, content: dict, collections: list = None)
Delete Document
delete_document(uri: str)
Search Documents
search_documents(
query: str = None, # String query (e.g., "marklogic and python")
structured_query: dict = None, # Structured query in JSON format
start: int = 1, # Starting position
page_length: int = 10 # Number of results per page
)
Get Database Information
get_database_info()
Example Usage
# Create a document
response = create_document(
uri="/documents/example.json",
content={"title": "Example", "content": "This is a test"},
collections=["test-collection"]
)
# Search using string query
response = search_documents(
query="marklogic and python",
start=1,
page_length=10
)
# Search using structured query
response = search_documents(
structured_query={
"query": {
"term-query": {
"text": ["marklogic"]
}
}
},
start=1,
page_length=10
)
Configuration
The server is configured using pyproject.toml. Here are the available configuration options:
[tool.marklogic]
host = "localhost" # MarkLogic server host
port = 8000 # MarkLogic server port
user = "admin" # MarkLogic username
password = "admin" # MarkLogic password
[tool.marklogic.logging]
level = "INFO" # Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" # Log format
Response Format
All operations return a dictionary with a status field indicating success or failure:
# Success response
{
"status": "success",
"message": "Operation result message",
"content": "Document content (for read operations)",
"total": "Total results (for search operations)",
"results": "Search results array",
"facets": "Search facets (if available)"
}
# Error response
{
"status": "error",
"message": "Error message"
}
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for marklogic-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| marklogic_mcp-0.1.0.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| marklogic_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / marklogic_mcp-0.1.0.tar.gz
| Download URL | marklogic_mcp-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f8b0d7428f94d053bd1c8787282952ecb9802f724fbd4f8dec61b16d18f9a21
|
|
BLAKE2b-256 checksum How to use checksums |
6a054e4ec0da6432e6647b41658071ba5f1e0cd50dcc66e70ab5b8ad309c629c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / marklogic_mcp-0.1.0-py3-none-any.whl
| Download URL | marklogic_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
011ca6f0d9e3662b72d7d33eacda8b0c7dd6c91e7eb9e3514114c6d859cc9ec1
|
|
BLAKE2b-256 checksum How to use checksums |
f438e379701a00dfb5cdbe0637f8a275af873296dacb649bf4849a5fbf2f9d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for marklogic-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.