Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update tests to be compatible with new OpenAI, MistralAI and MCP versions#2094

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
medaminezghal wants to merge20 commits intopydantic:main
base:main
Choose a base branch
Loading
frommedaminezghal:update-versins

Conversation

medaminezghal
Copy link
Contributor

@medaminezghalmedaminezghal commentedJun 28, 2025
edited
Loading

I've updated known model list with new OpenAI version, fixed MistralAItest issue in new version, added new ResourceLink MCP type and fixed tests for new MCP version.

@hyperlint-aiHyperlint AI
Copy link
Contributor

PR Change Summary

Updated tests to ensure compatibility with the latest versions of OpenAI, MistralAI, and MCP.

  • Updated known model list with the new OpenAI version
  • Fixed MistralAI test issue in the new version
  • Adjusted tests for compatibility with the new MCP version

Modified Files

  • docs/mcp/server.md

How can I customize these reviews?

Check out theHyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add thehyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to addhyperlint-ignore to the PR to ignore the link check for this PR.

Copy link
Contributor

@DouweMDouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@medaminezghal Thanks Mohamed! The only thing I'm not sure about is how we should handleResourceLink.

@DouweMDouweM self-assigned thisJun 30, 2025
@DouweM
Copy link
Contributor

@medaminezghal Can you please have a look at the failing coverage check?

@medaminezghal
Copy link
ContributorAuthor

medaminezghal commentedJul 9, 2025
edited
Loading

@DouweM Does it need to add some tests to fix coverage problem?

@DouweM
Copy link
Contributor

Does it need to add some tests to fix coverage problem?

@medaminezghal Yep, there are already a number oftest_tool_returning_<x> tests intests/test_mcp.py, and we'll want one forResourceLink. The test MCP server it uses is defined intests/mcp_server.py, so that's where you'll want to add a new@mcp.tool that returns aResourceLink, as well as an@mcp.resource that will return that actual resource once it's looked up.

@medaminezghal
Copy link
ContributorAuthor

medaminezghal commentedJul 9, 2025
edited
Loading

Does it need to add some tests to fix coverage problem?

@medaminezghal Yep, there are already a number oftest_tool_returning_<x> tests intests/test_mcp.py, and we'll want one forResourceLink. The test MCP server it uses is defined intests/mcp_server.py, so that's where you'll want to add a new@mcp.tool that returns aResourceLink, as well as an@mcp.resource that will return that actual resource once it's looked up.

Do I need a real API key to usemake update-vcr-tests?

@DouweM
Copy link
Contributor

DouweM commentedJul 9, 2025
edited
Loading

@medaminezghal I wouldn't usemake update-vcr-tests as it will try to update every single cassette. To just record a cassette for your own test, you can runpytest --record-mode=rewrite <test file path>::<test function name>. If the test uses a real model, you do need an API key.

@medaminezghal
Copy link
ContributorAuthor

@DouweM I don't have any API key to use it for tests, so, themake update-vcr-tests will not work.

Do you think I should use one of the file insidetests/assets/ for theResourceLink?

For example:

@mcp.tool()async def get_resource_link() -> ResourceLink:    return ResourceLink(        type='resource_link',        uri=AnyUrl(Path(__file__).parent.joinpath('assets/kiwi.png').absolute().as_uri()),        name='kiwi.png',    )

@DouweM
Copy link
Contributor

@medaminezghal I think you should only need the actual full file path in the@mcp.resource function that actually reads the resource, but yes using that file is great!

If you have your own OpenAI API key, you can generate the cassette for your new test with that, but if not feel free to push up the test and I can generate the cassette myself locally.

@medaminezghal
Copy link
ContributorAuthor

@DouweM I will just duplicate the tests that useEmbeddedResource to useResourceLink.

DouweM reacted with thumbs up emoji

Copy link
Contributor

@DouweMDouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@medaminezghal I was out for a few days but just had a chance to review this again. Please have a look at my comments and let me know if I can provide additional guidance (or take over).

async def get_image_resource_1() -> ResourceLink:
return ResourceLink(
type='resource_link',
uri=AnyUrl(Path(__file__).parent.joinpath('assets/kiwi.png').absolute().as_uri()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this need to be the full path? Couldn't it beAnyUrl('resource://kiwi.png') as above?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Theuri is used byclient.read_resource(), so, I think it should be the full path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@medaminezghal The path passed toclient.read_resource() is handled by the MCP server, so I think it can really be anything

)
return self._get_content(resource)
elif isinstance(part, mcp_types.ResourceLink):
resource_result: mcp_types.ReadResourceResult = await self._client.read_resource(part.uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

To make this work in the tests, I think we need to register each resource URI in the test server using@mcp.resource like here:https://github.com/modelcontextprotocol/python-sdk#resources

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@DouweM I think this only can be done usingFASTMCP.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@DouweM I didn't understand where should I add the@mcp.resource.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@medaminezghal In the sametests/mcp_server.py where you added the tools returningResourceLinks. When an MCP server tool returns a resource link with a URI, the client (Pydantic AI) can then ask the server for that resource by URI, so the tools and resource handlers should be implemented in the same place.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DouweMDouweMDouweM requested changes

Assignees

@DouweMDouweM

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@medaminezghal@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp