Skip to main content
Glama
dhipskind253

mssql-mcp

by dhipskind253

get_view_definition

Retrieve the SQL CREATE VIEW statement for a specified view in the database, using schema and view name.

Instructions

Return the SQL definition of a view.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYes
viewYes

Implementation Reference

  • src/index.ts:119-131 (registration)
    Registration of the 'get_view_definition' tool on the MCP server, defining its schema (schema and view string params) and handler which calls db.getViewDefinition().
    server.tool(
      'get_view_definition',
      'Return the SQL definition of a view.',
      {
        schema: z.string(),
        view: z.string(),
      },
      async ({ schema, view }) =>
        runTool(async () => {
          const def = await db.getViewDefinition(schema, view);
          return def ?? `[NOT_FOUND] View ${schema}.${view} not found.`;
        })
    );
  • Handler function that invokes db.getViewDefinition(schema, view) and returns the definition or a [NOT_FOUND] fallback.
    async ({ schema, view }) =>
      runTool(async () => {
        const def = await db.getViewDefinition(schema, view);
        return def ?? `[NOT_FOUND] View ${schema}.${view} not found.`;
      })
  • Zod schema defining the two required input parameters: schema (string) and view (string).
    {
      schema: z.string(),
      view: z.string(),
    },
  • The DbManager.getViewDefinition() method that queries sys.sql_modules joined with sys.views and sys.schemas to retrieve the SQL definition of a view.
    async getViewDefinition(schema: string, view: string): Promise<string | null> {
      const r = await (await this.getPool())
        .request()
        .input('schema', sql.NVarChar, schema)
        .input('view', sql.NVarChar, view).query(`
          SELECT m.definition
          FROM sys.sql_modules m
          INNER JOIN sys.views v ON m.object_id = v.object_id
          INNER JOIN sys.schemas s ON v.schema_id = s.schema_id
          WHERE s.name = @schema AND v.name = @view
        `);
      return r.recordset[0]?.definition ?? null;
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavior. It identifies the operation as read-only but omits permissions, error handling, or side effects.

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

Conciseness5/5

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

The description is a single concise sentence with no unnecessary words, achieving high efficiency.

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

Completeness1/5

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

With no annotations, no output schema, and zero param descriptions, the tool is severely underdocumented. The description covers only the bare minimum and fails to provide enough information for correct use.

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

Parameters2/5

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

Schema coverage is 0%, and the description does not explain or add meaning to the 'schema' and 'view' parameters beyond their names.

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 tool returns the SQL definition of a view, using a specific verb and resource. It distinguishes itself from siblings like describe_table and list_views.

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?

No guidance on when to use this tool versus alternatives like describe_table or get_procedure_definition. The description lacks context for selection.

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/dhipskind253/mssql-mcp'

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