Skip to main content
Glama

read_reference_file

Access reference documentation for financial research skills by reading files containing forms, specifications, or technical guides to support analysis tasks.

Instructions

Read a reference file from a skill (e.g., forms.md, reference.md, ooxml.md)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
skill_nameYesskill name
file_nameYesreference file name or file path

Implementation Reference

  • The async_execute method that performs the core logic of the read_reference_file tool: retrieves parameters, locates the skill directory, constructs and reads the file path, handles missing files.
    async def async_execute(self): """Execute the read reference file operation. Reads a reference file from the specified skill directory. The method retrieves the skill directory from the context's skill metadata dictionary, constructs the file path, and reads the file content if it exists. The method: 1. Extracts the skill_name and file_name from input_dict 2. Looks up the skill directory from skill_metadata_dict 3. Constructs the file path as {skill_dir}/{file_name} 4. Checks if the file exists 5. Reads the file content if it exists 6. Returns the file content or an error message if not found Returns: None: The result is set via `self.set_output()` with one of: - The file content (as a string) if the file exists - An error message string if the file is not found Raises: KeyError: If skill_name is not found in skill_metadata_dict. This should be handled by ensuring LoadSkillMetadataOp is called before ReadReferenceFileOp. Note: - The file path is constructed as: {skill_dir}/{file_name} - File encoding is assumed to be UTF-8 - If the file does not exist, an error message is returned instead of raising an exception """ skill_name = self.input_dict["skill_name"] file_name = self.input_dict["file_name"] # skill_dir = Path(self.context.skill_metadata_dict[skill_name]["skill_dir"]) skill_dir = Path(C.service_config.metadata["skill_dir"]) ### logger.info( f"🔧 Tool called: read_reference_file(skill_name='{skill_name}', file_name='{file_name}') " f"with skill_dir={skill_dir}", ) file_path = skill_dir / skill_name / file_name ### if not file_path.exists(): content = f"File '{file_name}' not found in skill '{skill_name}'" logger.exception(content) self.set_output(content) return result = file_path.read_text(encoding="utf-8") logger.info(f"✅ Read file: {skill_name}/{file_name} size={len(result)}") self.set_output(result)
  • The build_tool_call method returns the ToolCall definition including the tool name 'read_reference_file' and its input schema requiring 'skill_name' and 'file_name'.
    return ToolCall( **{ "name": "read_reference_file", "description": "Read a reference file from a skill (e.g., forms.md, reference.md, ooxml.md)", "input_schema": { "skill_name": { "type": "string", "description": "skill name", "required": True, }, "file_name": { "type": "string", "description": "reference file name or file path", "required": True, }, }, }, )
  • The ReadReferenceFileOp class is registered as an operation using the @C.register_op() decorator, making it available as the 'read_reference_file' tool.
    @C.register_op() class ReadReferenceFileOp(BaseAsyncToolOp):

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/zouyingcao/agentskills-mcp'

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