Skip to content

Add stored procedure and function tools with comprehensive test coverage #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shubham070
Copy link

🚀 Overview

This PR implements comprehensive support for SQL Server stored procedures and functions in the MCP server, including execution capabilities, metadata retrieval, and robust test coverage.

✨ Features Added

New MCP Tools (4 tools)

  • ExecuteStoredProcedure - Execute stored procedures with optional parameters
  • ExecuteFunction - Execute table-valued functions with optional parameters
  • ListProceduresAndFunctions - List all stored procedures and functions in the database
  • DescribeProcedureOrFunction - Get detailed metadata about specific procedures/functions

Comprehensive Test Coverage

  • 16 Unit Tests - Fast, isolated tests without database dependencies
  • 14 Integration Tests - End-to-end testing with real SQL Server (existing tests preserved)
  • Test Documentation - Complete README with best practices and execution commands

🔧 Technical Implementation

Core Features

  • Parameter validation and sanitization for security
  • Support for both parameterized and parameterless execution
  • Comprehensive error handling and logging
  • Consistent return format following existing MCP patterns
  • Full metadata extraction including parameter definitions

Architecture Improvements

  • Clean separation between unit and integration tests
  • Follows Test Pyramid principle for optimal feedback cycles
  • Maintains existing code patterns and conventions
  • Zero breaking changes to existing functionality

🧪 Testing Strategy

Unit Tests (ToolsUnitTests.cs)

dotnet test --filter "FullyQualifiedName~ToolsUnitTests"
# ✅ 16 tests, ~1.2s execution time, no database required

…tools

- Add ListProceduresAndFunctions tool to list all stored procedures and functions
- Add DescribeProcedureOrFunction tool to get detailed information about procedures/functions
- Include parameter information, definitions, and metadata
- Both tools follow existing patterns with proper error handling and logging
…cuteFunction tools

- Add ToolsUnitTests.cs with 16 fast unit tests covering:
  * Parameter validation for stored procedures and functions
  * Constructor and interface validation for Tools class
  * SqlConnectionFactory interface verification
  * Various parameter types and null value handling

- Add comprehensive test documentation (README.md) explaining:
  * Separation between unit tests (fast, no dependencies) and integration tests
  * Test execution commands and prerequisites
  * Test coverage matrix for all tools
  * Best practices following Test Pyramid principle

- Maintain clean architecture:
  * Unit tests (16) - Fast validation without database dependencies
  * Integration tests (14) - End-to-end database testing (unchanged)
  * Total coverage: 30 tests across all MCP tools

This addresses missing test coverage for the ExecuteStoredProcedure and
ExecuteFunction tools added in previous commits while maintaining proper
separation of concerns between unit and integration testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant