This guide covers local development, testing, and contributing to the MCP LogSeq server.
- Python 3.11 or higher
- uv for Python package management
- LogSeq with HTTP API enabled
- Git
# Clone the repository
git clone https://github.com/ergut/mcp-logseq.git
cd mcp-logseq
# Install dependencies
uv sync
# Install development dependencies (including vector extras required for tests)
uv sync --dev --extra vectorCreate a .env file in the project root:
LOGSEQ_API_TOKEN=your_token_here
LOGSEQ_API_URL=http://localhost:12315# Add to Claude Code with local development setup
claude mcp add mcp-logseq-dev \
--env LOGSEQ_API_TOKEN=your_token_here \
--env LOGSEQ_API_URL=http://localhost:12315 \
-- uv run --directory /path/to/mcp-logseq mcp-logseq{
"mcpServers": {
"mcp-logseq-dev": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-logseq",
"mcp-logseq"
],
"env": {
"LOGSEQ_API_TOKEN": "your_token_here",
"LOGSEQ_API_URL": "http://localhost:12315"
}
}
}
}# Run all tests
uv run pytest
# Run tests with verbose output
uv run pytest -v
# Run specific test categories
uv run pytest tests/unit/ # Unit tests only
uv run pytest tests/integration/ # Integration tests only
# Run with coverage
uv run pytest --cov=mcp_logseq --cov-report=html- Unit tests: Test individual components (LogSeq API client, tool handlers)
- Integration tests: Test MCP server functionality end-to-end
- HTTP mocking: Uses
responseslibrary for reliable testing - 50+ comprehensive tests with 100% success rate
For detailed testing documentation, see TESTING.md.
The best way to debug MCP servers is using the MCP Inspector:
# Debug local development version
npx @modelcontextprotocol/inspector \
uv run --directory /path/to/mcp-logseq mcp-logseqTest the LogSeq API connection directly:
# Test API connectivity
uv run python -c "
from mcp_logseq.logseq import LogSeq
api = LogSeq(api_key='your_token')
result = api.list_pages()
print(f'Connected! Found {len(result)} pages')
"
# Test specific API endpoints
uv run python -c "
from mcp_logseq.logseq import LogSeq
api = LogSeq(api_key='your_token')
print('Testing create_page...')
api.create_page('Test Page', 'Test content')
print('Success!')
"The server uses comprehensive logging. Check the log file:
# Log file is now stored in user cache directory
tail -f ~/.cache/mcp-logseq/mcp_logseq.logmcp-logseq/
├── src/mcp_logseq/
│ ├── __init__.py # Package entry point
│ ├── server.py # MCP server initialization
│ ├── logseq.py # LogSeq API client
│ └── tools.py # MCP tool handlers
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── README.md # User documentation
├── DEVELOPMENT.md # This file
├── ROADMAP.md # Project roadmap
├── pyproject.toml # Package configuration
└── .env.example # Environment template
server.py: MCP server setup, tool registration, request handlinglogseq.py: LogSeq API client with JSON-RPC methodstools.py: Tool handlers that transform API responses for Claude
Each LogSeq operation is implemented as a ToolHandler subclass:
class ExampleToolHandler(ToolHandler):
def get_tool_description(self) -> Tool:
# Define tool schema
def run_tool(self, args: dict) -> list[TextContent]:
# Implement tool logic- Run tests: Ensure all tests pass
- Check typing: Run
uv run pyright - Test locally: Verify with both Claude Code and Claude Desktop
- Update docs: Update README.md or DEVELOPMENT.md if needed
- Follow existing patterns in the codebase
- Use type hints for all functions
- Add comprehensive error handling
- Include logging for debugging
- Create a new
ToolHandlersubclass intools.py - Implement required methods
- Register the tool in
server.py - Add corresponding LogSeq API method if needed
- Write unit and integration tests
- Update documentation
# Sync dependencies
uv sync
# Run all tests
uv run pytest
# Check package can be built
uv build# Build the package
uv build
# Publish (requires credentials)
uv publish- Import errors: Make sure you're in the project directory and dependencies are installed
- API connection failures: Verify LogSeq is running and API server is started
- Token issues: Check that your
.envfile has the correct token - MCP client issues: Restart Claude Code/Desktop after configuration changes
- Check existing issues: https://github.com/ergut/mcp-logseq/issues
- Review LogSeq API documentation
- Use MCP Inspector for debugging
- Check Claude Code/Desktop documentation for MCP setup