Skip to main content
Glama

find_site_by_domain

Search across all servers for a site by domain name using partial match. Quickly locate any site linked to a domain in your Ploi infrastructure.

Instructions

Search for a site by domain name across all servers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesThe domain name to search for (partial match supported)

Implementation Reference

  • The `registerSiteTools` function is exported and called from `src/tools/index.ts` (via `registerAllTools`), which registers all tools including 'find_site_by_domain' on the MCP server.
    export function registerSiteTools(server: McpServer, client: PloiClient) {
      server.tool(
        "list_sites",
        "List all sites on a server",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
        },
        async ({ server_id }) => {
          const sites = await client.listSites(server_id);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(sites, null, 2),
              },
            ],
          };
        }
      );
    
      server.tool(
        "get_site",
        "Get details of a specific site",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
          site_id: z.coerce.number().describe("The ID of the site"),
        },
        async ({ server_id, site_id }) => {
          const site = await client.getSite(server_id, site_id);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(site, null, 2),
              },
            ],
          };
        }
      );
    
      server.tool(
        "deploy_site",
        "Trigger deployment for a site and wait for it to complete. Returns status when done.",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
          site_id: z.coerce.number().describe("The ID of the site to deploy"),
        },
        async ({ server_id, site_id }) => {
          await client.deploySite(server_id, site_id);
    
          // Poll until deployment completes (max 5 minutes)
          const maxAttempts = 60;
          const pollInterval = 5000; // 5 seconds
    
          for (let attempt = 0; attempt < maxAttempts; attempt++) {
            await new Promise(resolve => setTimeout(resolve, pollInterval));
    
            const site = await client.getSite(server_id, site_id);
    
            if (site.status === "active") {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: `✅ Deployment successful!\n\nSite: ${site.domain}\nStatus: ${site.status}`,
                  },
                ],
              };
            }
    
            if (site.status !== "deploying") {
              // Some other status (error, etc)
              return {
                content: [
                  {
                    type: "text" as const,
                    text: `⚠️ Deployment ended with status: ${site.status}\n\nSite: ${site.domain}`,
                  },
                ],
              };
            }
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: `⏱️ Deployment still in progress after 5 minutes. Check status manually.`,
              },
            ],
          };
        }
      );
    
      server.tool(
        "get_site_logs",
        "Get deployment/site logs",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
          site_id: z.coerce.number().describe("The ID of the site"),
        },
        async ({ server_id, site_id }) => {
          try {
            const logs = await client.getSiteLogs(server_id, site_id);
            return {
              content: [
                {
                  type: "text" as const,
                  text: String(logs || "No logs available"),
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Error fetching site logs: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
            };
          }
        }
      );
    
      server.tool(
        "suspend_site",
        "Suspend a site",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
          site_id: z.coerce.number().describe("The ID of the site to suspend"),
        },
        async ({ server_id, site_id }) => {
          await client.suspendSite(server_id, site_id);
          return {
            content: [
              {
                type: "text" as const,
                text: `Site ${site_id} on server ${server_id} has been suspended`,
              },
            ],
          };
        }
      );
    
      server.tool(
        "resume_site",
        "Resume a suspended site",
        {
          server_id: z.coerce.number().describe("The ID of the server"),
          site_id: z.coerce.number().describe("The ID of the site to resume"),
        },
        async ({ server_id, site_id }) => {
          await client.resumeSite(server_id, site_id);
          return {
            content: [
              {
                type: "text" as const,
                text: `Site ${site_id} on server ${server_id} has been resumed`,
              },
            ],
          };
        }
      );
    
      server.tool(
        "deploy_project",
        "Deploy the current project using .ploi.json config file and wait for completion. Use this when the user says 'deploy' without specifying a site.",
        {
          project_path: z.string().describe("The path to the project directory containing .ploi.json"),
        },
        async ({ project_path }) => {
          const config = await readPloiConfig(project_path);
          if (!config) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No .ploi.json config found in ${project_path}. Create one with:\n{\n  "server_id": YOUR_SERVER_ID,\n  "site_id": YOUR_SITE_ID\n}\n\nOr use: "link this project to yourdomain.com"`,
                },
              ],
            };
          }
    
          const initialSite = await client.getSite(config.server_id, config.site_id);
          await client.deploySite(config.server_id, config.site_id);
    
          // Poll until deployment completes (max 5 minutes)
          const maxAttempts = 60;
          const pollInterval = 5000; // 5 seconds
    
          for (let attempt = 0; attempt < maxAttempts; attempt++) {
            await new Promise(resolve => setTimeout(resolve, pollInterval));
    
            const site = await client.getSite(config.server_id, config.site_id);
    
            if (site.status === "active") {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: `✅ Deployment successful!\n\nSite: ${site.domain}\nStatus: ${site.status}`,
                  },
                ],
              };
            }
    
            if (site.status !== "deploying") {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: `⚠️ Deployment ended with status: ${site.status}\n\nSite: ${site.domain}`,
                  },
                ],
              };
            }
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: `⏱️ Deployment still in progress after 5 minutes for ${initialSite.domain}. Check status manually.`,
              },
            ],
          };
        }
      );
    
      server.tool(
        "get_project_deploy_status",
        "Check deployment status for the current project using .ploi.json config",
        {
          project_path: z.string().describe("The path to the project directory containing .ploi.json"),
        },
        async ({ project_path }) => {
          const config = await readPloiConfig(project_path);
          if (!config) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No .ploi.json config found in ${project_path}`,
                },
              ],
            };
          }
    
          const site = await client.getSite(config.server_id, config.site_id);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({
                  domain: site.domain,
                  status: site.status,
                  server_id: config.server_id,
                  site_id: config.site_id,
                }, null, 2),
              },
            ],
          };
        }
      );
    
      server.tool(
        "find_site_by_domain",
        "Search for a site by domain name across all servers",
        {
          domain: z.string().describe("The domain name to search for (partial match supported)"),
        },
        async ({ domain }) => {
          const servers = await client.listServers();
          const results: Array<{ server_id: number; server_name: string; site: Site }> = [];
    
          for (const server of servers) {
            const sites = await client.listSites(server.id);
            for (const site of sites) {
              if (site.domain.toLowerCase().includes(domain.toLowerCase())) {
                results.push({
                  server_id: server.id,
                  server_name: server.name,
                  site,
                });
              }
            }
          }
    
          if (results.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No sites found matching "${domain}"`,
                },
              ],
            };
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(results, null, 2),
              },
            ],
          };
        }
      );
    
      server.tool(
        "init_project",
        "Initialize .ploi.json config for a project by searching for a domain. Use when user wants to link a project to a Ploi site.",
        {
          project_path: z.string().describe("The path to the project directory"),
          domain: z.string().describe("The domain name of the Ploi site to link"),
        },
        async ({ project_path, domain }) => {
          const servers = await client.listServers();
          let foundServer: { id: number; name: string } | null = null;
          let foundSite: Site | null = null;
    
          for (const server of servers) {
            const sites = await client.listSites(server.id);
            for (const site of sites) {
              if (site.domain.toLowerCase().includes(domain.toLowerCase())) {
                foundServer = { id: server.id, name: server.name };
                foundSite = site;
                break;
              }
            }
            if (foundSite) break;
          }
    
          if (!foundSite || !foundServer) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No site found matching "${domain}". Use list_servers and list_sites to find your site.`,
                },
              ],
            };
          }
    
          const config = {
            server_id: foundServer.id,
            site_id: foundSite.id,
          };
    
          const configPath = join(project_path, ".ploi.json");
          await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Created .ploi.json for ${foundSite.domain}\n\nServer: ${foundServer.name} (${foundServer.id})\nSite: ${foundSite.domain} (${foundSite.id})\n\nYou can now use "deploy" to deploy this project.`,
              },
            ],
          };
        }
      );
    }
  • The handler for the 'find_site_by_domain' tool. It iterates over all servers, lists sites on each, does a case-insensitive partial match on the domain, and returns matching results.
    server.tool(
      "find_site_by_domain",
      "Search for a site by domain name across all servers",
      {
        domain: z.string().describe("The domain name to search for (partial match supported)"),
      },
      async ({ domain }) => {
        const servers = await client.listServers();
        const results: Array<{ server_id: number; server_name: string; site: Site }> = [];
    
        for (const server of servers) {
          const sites = await client.listSites(server.id);
          for (const site of sites) {
            if (site.domain.toLowerCase().includes(domain.toLowerCase())) {
              results.push({
                server_id: server.id,
                server_name: server.name,
                site,
              });
            }
          }
        }
    
        if (results.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: `No sites found matching "${domain}"`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      }
    );
  • The input schema: requires a `domain` string parameter (supports partial match) defined using Zod.
    {
      domain: z.string().describe("The domain name to search for (partial match supported)"),
    },
  • The `registerAllTools` function that dispatches to `registerSiteTools`, which registers the 'find_site_by_domain' tool.
    export function registerAllTools(server: McpServer, client: PloiClient) {
      registerServerTools(server, client);
      registerSiteTools(server, client);
      registerDatabaseTools(server, client);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It lacks details on search behavior, return format, multiple matches, not-found cases, or read-only nature. Only 'across all servers' adds some scope context.

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

Conciseness3/5

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

Single sentence, concise but minimal. Lacks structured front-loading of key details; adequate but not exemplary.

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?

With no output schema, no annotations, and only one sentence, the description is incomplete. It omits return behavior, error handling, and practical usage context for a search tool.

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 covers 100% of parameters with a clear description including 'partial match supported'. The tool description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the verb 'search', the resource 'site', the attribute 'domain name', and the scope 'across all servers'. This distinguishes it from siblings like get_site or list_sites.

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

Usage Guidelines3/5

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

The description does not explicitly state when to use this tool versus alternatives like get_site or list_sites. It only implies usage via its purpose, but no direct guidance is provided.

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/sudanese/ploi-mcp'

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