Skip to main content
Glama

get_last_run

Retrieve the most recent run artifact for a specific target ID from the MCP Observatory's default runs directory to access previous execution results.

Instructions

Return the most recent run artifact for a given target ID. Searches the default runs directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetIdYesThe target ID to find the last run for (e.g. server name or command).
runsDirNoCustom runs directory. Defaults to .mcp-observatory/runs in cwd.

Implementation Reference

  • The MCP tool 'get_last_run' is registered and implemented directly within src/server.ts. It processes the request, locates the relevant artifact file, and returns its content.
    server.tool(
      "get_last_run",
      "Return the most recent run artifact for a given target ID. Searches the default runs directory.",
      {
        targetId: z.string().describe("The target ID to find the last run for (e.g. server name or command)."),
        runsDir: z.string().optional().describe("Custom runs directory. Defaults to .mcp-observatory/runs in cwd."),
      },
      async ({ targetId, runsDir }) => {
        try {
          const dir = runsDir ?? defaultRunsDirectory();
          let files: string[];
          try {
            files = await readdir(dir);
          } catch {
            return { content: [{ type: "text" as const, text: `No runs directory found at ${dir}` }], isError: true };
          }
    
          // Filter to JSON files matching the target, sorted newest-first by filename (ISO timestamp prefix)
          const needle = targetId.toLowerCase();
          const matching = files
            .filter((f) => f.endsWith(".json") && f.toLowerCase().includes(needle))
            .sort()
            .reverse();
    
          if (matching.length === 0) {
            return { content: [{ type: "text" as const, text: `No run artifacts found for target "${targetId}" in ${dir}` }] };
          }
    
          const latest = matching[0]!;
          const artifact = await readArtifact(path.join(dir, latest));
          if (artifact.artifactType !== "run") {
            return { content: [{ type: "text" as const, text: `Latest matching file is not a run artifact: ${latest}` }], isError: true };
          }
    
          return {
            content: [{ type: "text" as const, text: `${formatRun(artifact)}\n\nFile: ${path.join(dir, latest)}` }],
          };
        } catch (error) {
          const msg = error instanceof Error ? error.message : String(error);
          return { content: [{ type: "text" as const, text: `Error reading last run: ${msg}` }], isError: true };
        }
      },
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/KryptosAI/mcp-observatory'

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