Skip to content

Conversation

@wgillett
Copy link
Contributor

Using environment variables is helpful to be able to check mcp.json into source control without embedding secrets, and to be able to vary configuration values dynamically.
In load_mcp_servers, expand any environment variables. Throw an exception if any variables don't have values.
Add tests and document the use of environment variables.

@Kludex Kludex self-assigned this Nov 10, 2025
Walter Gillett and others added 2 commits November 10, 2025 14:50
@wgillett
Copy link
Contributor Author

@DouweM Thanks for the feedback. I have addressed all of it. Please let me know if there is more to do here, or if you are ready to remove the "awaiting author revision" label.

@DouweM
Copy link
Collaborator

DouweM commented Nov 10, 2025

@wgillett Thanks for the updates Walter! As @Kludex assigned this to himself, I'll leave it to him to do a final review and merge this once he deems it ready.

Comment on lines 124 to 136
async def test_is_running():
"""Test the is_running property."""
server = MCPServerStdio('python', ['-m', 'tests.mcp_server'])

# Server should not be running initially
assert not server.is_running

# Server should be running inside the context manager
async with server:
assert server.is_running

# Server should not be running after exiting the context manager
assert not server.is_running
Copy link
Member

Choose a reason for hiding this comment

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

What's this test about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kludex I added this for test coverage. When I ran MCP tests, that showed is_running as not covered. Looking at this again, I see that is_running is actually exercised by test_agent.py, but it's all indirect. Having a test specifically for this function seems like a good idea to me.

Copy link
Member

Choose a reason for hiding this comment

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

Please drop this test.

I don't agree that we should be testing private attributes/behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kludex I have removed the test as requested. Agree with not testing private attributes/behavior. For future reference, how would I tell that is_running is private? I expect private members to be named with a leading underscore.

@Kludex Kludex assigned DouweM and unassigned Kludex Nov 12, 2025
@wgillett
Copy link
Contributor Author

@Kludex Thanks for the feedback. I have responded to all of it. Please let me know if more changes are needed.

@Kludex
Copy link
Member

Kludex commented Nov 13, 2025

After #3380 (comment), we can merge it.

Thanks! 🙏

@wgillett
Copy link
Contributor Author

@Kludex wrote "After #3380 (comment), we can merge it."
I have taken care of that so we should be good to go.

@DouweM DouweM changed the title Make it possible to use environment variables in mcp.json Support mcp.json environment variable expansion in load_mcp_servers() Nov 13, 2025
@DouweM DouweM enabled auto-merge (squash) November 13, 2025 23:46
@DouweM DouweM merged commit 6fe5146 into pydantic:main Nov 13, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants