Skip to main content
Glama
fkesheh
by fkesheh

create_skill_file

Create new files within skill directories to build Python scripts, configuration files, data files, and documentation while automatically creating necessary parent directories.

Instructions

Create a new file within a skill directory. Automatically creates parent directories if they don't exist.

This tool allows you to:

  • Create new Python scripts or other executable files

  • Create configuration files (e.g., JSON, YAML, CSV)

  • Create data files and documentation

  • Build new functionality within a skill

Parameters:

  • skill_name: The name of the skill directory (e.g., 'my-skill')

  • file_path: Relative path for the new file (e.g., 'scripts/new_script.py', 'data/new_data.json')

  • content: The complete text content to write to the file

Behavior:

  • Creates parent directories automatically (e.g., if 'scripts/' doesn't exist, it will be created)

  • Does not overwrite existing files (use update_skill_file to modify existing files)

  • File_path must be relative to the skill's root directory

  • Use forward slashes for path separators

Returns: Success message with filename and character count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to write to the file
file_pathYesRelative path for the new file within the skill directory
skill_nameYesName of the skill

Implementation Reference

  • Pydantic input schema for the create_skill_file tool.
    class CreateSkillFileInput(BaseModel): """Input for creating a new skill file.""" skill_name: str = Field(description="Name of the skill") file_path: str = Field(description="Relative path for the new file within the skill directory") content: str = Field(description="Content to write to the file")
  • Core helper function that implements the logic to create a new file in a skill directory. Used by CRUD tools.
    def create_file(skill_name: str, file_path: str, content: str) -> None: """ Create a new skill file. Args: skill_name: Name of the skill file_path: Relative path for the new file content: File content Raises: SkillNotFoundError: If skill doesn't exist InvalidPathError: If path is invalid FileNotFoundError: If file already exists """ # Check if skill exists first skill_dir = SKILLS_DIR / skill_name if not skill_dir.exists(): raise SkillNotFoundError(f"Skill '{skill_name}' does not exist") if not skill_dir.is_dir(): raise SkillNotFoundError(f"'{skill_name}' is not a directory") full_path = validate_path(skill_name, file_path) if full_path.exists(): raise FileNotFoundError( f"File '{file_path}' already exists in skill '{skill_name}'. " "Use update to modify it." ) # Create parent directories if needed full_path.parent.mkdir(parents=True, exist_ok=True) # Write content full_path.write_text(content) @staticmethod
  • Handler for file creation within the 'skill_files_crud' tool (operation='create'). This is the closest match to create_skill_file functionality, calling FileService.create_file.
    async def _handle_create(input_data: SkillFilesCrudInput) -> list[types.TextContent]: """Handle create operation (single or bulk).""" # Bulk operation if input_data.files: if input_data.file_path or input_data.content: return [ types.TextContent( type="text", text="Error: Cannot specify both 'files' (bulk) and 'file_path'/'content' (single) parameters", ) ] # Manually implement bulk creation with atomicity created_files = [] try: for file_spec in input_data.files: FileService.create_file( input_data.skill_name, file_spec.path, file_spec.content ) created_files.append(file_spec.path) # Use namespaced paths in output namespaced_files = [f"{input_data.skill_name}:{f}" for f in created_files] return [ types.TextContent( type="text", text=f"Successfully created {len(created_files)} files:\n" + "\n".join(f" - {f}" for f in namespaced_files), ) ] except Exception as e: # Rollback on error if atomic mode if input_data.atomic: from skill_mcp.core.config import SKILLS_DIR skill_dir = SKILLS_DIR / input_data.skill_name for created_path in created_files: try: (skill_dir / created_path).unlink() except Exception: pass raise e # Single operation if not input_data.file_path or not input_data.content: return [ types.TextContent( type="text", text="Error: file_path and content are required for single file create", ) ] FileService.create_file(input_data.skill_name, input_data.file_path, input_data.content) namespaced_path = f"{input_data.skill_name}:{input_data.file_path}" return [ types.TextContent( type="text", text=f"Successfully created file '{namespaced_path}' ({len(input_data.content)} characters)", ) ]

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/fkesheh/skill-mcp'

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