Skip to main content
Glama
dweigend

Joplin MCP Server

by dweigend

import_markdown

Convert a markdown file into a Joplin note by specifying its file path. This tool adds external markdown content to your Joplin workspace for organization and editing.

Instructions

Import a markdown file as a new note.

Args:
    args: Import parameters
        file_path: Path to the markdown file

Returns:
    Dictionary containing the created note data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsYes

Implementation Reference

  • The handler function for the 'import_markdown' tool, including the @mcp.tool() decorator for registration. It processes the input file path, parses the Markdown content using a helper utility, and creates a new note in Joplin.
    @mcp.tool()
    async def import_markdown(args: ImportMarkdownInput) -> Dict[str, Any]:
        """Import a markdown file as a new note.
        
        Args:
            args: Import parameters
                file_path: Path to the markdown file
        
        Returns:
            Dictionary containing the created note data
        """
        if not api:
            return {"error": "Joplin API client not initialized"}
        
        try:
            file_path = Path(args.file_path)
            md_content = MarkdownContent.from_file(file_path)
            
            note = api.create_note(
                title=md_content.title,
                body=md_content.content
            )
            
            return {
                "status": "success",
                "note": {
                    "id": note.id,
                    "title": note.title,
                    "body": note.body,
                    "created_time": note.created_time.isoformat() if note.created_time else None,
                    "updated_time": note.updated_time.isoformat() if note.updated_time else None,
                    "is_todo": note.is_todo
                },
                "imported_from": str(file_path)
            }
        except Exception as e:
            logger.error(f"Error importing markdown: {e}")
            return {"error": str(e)}
  • Pydantic input schema for the import_markdown tool, defining the required 'file_path' parameter.
    class ImportMarkdownInput(BaseModel):
        """Input parameters for importing markdown files."""
        file_path: str
  • Helper classmethod MarkdownContent.from_file() that parses a markdown file, extracts title from first H1 or filename, and provides content, used directly in the import_markdown handler.
    @classmethod
    def from_file(cls, file_path: Path) -> 'MarkdownContent':
        """Create MarkdownContent from a file.
        
        Args:
            file_path: Path to the markdown file
            
        Returns:
            MarkdownContent instance
            
        Raises:
            FileNotFoundError: If the file doesn't exist
            ValueError: If the file is empty or invalid
        """
        if not file_path.exists():
            raise FileNotFoundError(f"File not found: {file_path}")
    
        if not file_path.is_file():
            raise ValueError(f"Not a file: {file_path}")
    
        content = file_path.read_text(encoding='utf-8')
        if not content.strip():
            raise ValueError(f"File is empty: {file_path}")
    
        # Extract title from first heading or use filename
        lines = content.splitlines()
        title = file_path.stem
    
        for line in lines:
            if line.startswith('# '):
                title = line[2:].strip()
                content = '\n'.join(lines[1:]).strip()
                break
    
        return cls(
            title=title,
            content=content,
            source_path=file_path,
            created_time=datetime.fromtimestamp(file_path.stat().st_ctime),
            modified_time=datetime.fromtimestamp(file_path.stat().st_mtime)
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool creates a new note, implying a write operation, but doesn't cover permissions, error handling, or side effects. It mentions a return value ('Dictionary containing the created note data') but lacks details on structure or potential failures.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by structured sections for args and returns. It's efficient with minimal waste, though the 'args' section could be more directly integrated. Overall, it's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema description coverage, and no output schema, the description is incomplete. It covers the basic operation and parameter but lacks details on behavioral traits, error cases, and return value structure. For a write tool with undocumented parameters, this leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It documents one parameter ('file_path: Path to the markdown file'), which matches the single parameter in the schema. However, it doesn't explain format expectations (e.g., absolute vs. relative paths, file extensions) or validation rules, leaving gaps in understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Import a markdown file as a new note.' This specifies the verb ('import'), resource ('markdown file'), and outcome ('new note'). However, it doesn't explicitly differentiate from sibling tools like 'create_note', which might create notes from other sources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'create_note' for non-markdown creation or 'search_notes' for finding existing notes. There's no context about prerequisites, such as file accessibility or format requirements.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dweigend/joplin-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server