Skip to content

Conversation

@piyusht-square
Copy link

@piyusht-square piyusht-square commented Jan 28, 2026

Description

Adds comprehensive unit test coverage for the mcp-server-fetch server, which previously had no tests.

Server Details

  • Server: fetch
  • Changes to: tests, dev dependencies

Motivation and Context

The fetch server is one of the core reference servers but had 0% test coverage. This PR brings it in line with other servers (git, time, filesystem) that have comprehensive test suites.

How Has This Been Tested?

All 20 tests pass locally:

$ uv run pytest tests/ -v
======================== 20 passed in 1.49s ========================

Tests cover:

  • TestGetRobotsTxtUrl: 6 tests for URL parsing (paths, ports, query params, fragments)
  • TestExtractContentFromHtml: 3 tests for HTML-to-markdown conversion, error handling
  • TestCheckMayAutonomouslyFetchUrl: 5 tests for robots.txt permission checking (401/403/404/allow/disallow)
  • TestFetchUrl: 6 tests for HTTP responses, raw mode, proxy support

Breaking Changes

None. This PR only adds tests, no changes to server behavior.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally

Additional context

New test file: src/fetch/tests/test_server.py

Updated pyproject.toml:

  • Added pytest and pytest-asyncio as dev dependencies
  • Added pytest configuration section

@piyusht-square piyusht-square force-pushed the add-fetch-server-tests branch 2 times, most recently from c7e0579 to fc242e0 Compare January 28, 2026 22:30
Add comprehensive test coverage for the fetch server:
- TestGetRobotsTxtUrl: 6 tests for URL parsing
- TestExtractContentFromHtml: 3 tests for HTML-to-markdown conversion
- TestCheckMayAutonomouslyFetchUrl: 5 tests for robots.txt handling
- TestFetchUrl: 6 tests for URL fetching with various scenarios

Total: 20 tests covering:
- URL parsing and robots.txt URL generation
- HTML content extraction and markdown conversion
- robots.txt permission checking (401, 403, 404, allow/disallow)
- HTTP response handling (success, errors, raw mode)
- Proxy support

Also adds pytest and pytest-asyncio as dev dependencies.
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