Skip to content

MCP Server instructions are currently ignored #704

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

Closed
2 tasks done
bocytko opened this issue May 15, 2025 · 9 comments
Closed
2 tasks done

MCP Server instructions are currently ignored #704

bocytko opened this issue May 15, 2025 · 9 comments
Labels
question Question about using the SDK

Comments

@bocytko
Copy link

bocytko commented May 15, 2025

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have had similar requests

Question

MCP Servers define instructions, for example the aws-documentation-mcp-server.

Instructions are currently ignored in the Agent execution flow. It only reads mcp tools and converts these to LLM tool descriptions. Is this an explicit design decision?

@bocytko bocytko added the question Question about using the SDK label May 15, 2025
@rm-openai
Copy link
Collaborator

Not explicit, I didn't realize this existed. From the docs, looks like instructions is optional and it says

For example, this information MAY be added to the system prompt.

We could add a way for you to fetch the instructions, and then you can choose to append that to the system prompt. Open to other ideas too.

@bocytko
Copy link
Author

bocytko commented May 15, 2025

We could add a way for you to fetch the instructions, and then you can choose to append that to the system prompt.

This sounds intuitive enough to me. Shall I file a separate feature request?

@rm-openai
Copy link
Collaborator

Nope, we can use this issue. PR also welcome!

@DanieleMorotti
Copy link
Contributor

DanieleMorotti commented May 16, 2025

Hi @bocytko, if you haven’t started on this yet I’d be happy to implement this feature.
I found that the instructions are included in the instructions field of the session‐initialization response. We could store it on the server and inject them into the prompt where needed.

@bocytko
Copy link
Author

bocytko commented May 16, 2025

@DanieleMorotti please go ahead. Thank you in advance!

@DanieleMorotti
Copy link
Contributor

@rm-openai I can do something like this:

server_result = await session.initialize()
self.mcp_instructions = server_result.instructions or None

in src/agents/mcp/server.py at line 125. But how / where to pass this variable only for the tools related to a specific server? In the FunctionTool object?

@rm-openai
Copy link
Collaborator

@DanieleMorotti wdym? I don't think you need to do anything else. Once you do that, users will be able to do this:

async with MCPServerStreamableHttp(...) as server:
  agent = Agent(..., mcp_servers=[server], instructions=f"...MCP instructions: {server.instructions}")

@DanieleMorotti
Copy link
Contributor

Ok sorry, I thought it should be injected to the prompt somehow but instead users will directly choose how to adopt instructions.

@rm-openai
Copy link
Collaborator

Ah yup, prefer to leave it to users - less magic that way.

rm-openai pushed a commit that referenced this issue May 18, 2025
Added the `instructions` attribute to the MCP servers to solve #704 .

Let me know if you want to add an example to the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

3 participants