Third-Party MCP Servers
1. Third-Party MCP Servers
Welcome back! Throughout this course, we've built our own MCP servers and wired them to databases and APIs, but you don't have to build everything yourself.2. Why Use Third-Party MCP Servers?
Third-party MCP servers let you add capabilities quickly. If you need access to a filesystem or to a specific database provider, chances are that an MCP server already exists. There are repositories, like the one shown, for quickly searching for official and community MCP servers.3. Why Use Third-Party MCP Servers?
If there are established tools you already work with, chances are they support an MCP server and have documentation on how to use it. Someone else maintains the server code and deals with API changes, and you can focus on developing your application. The client talks to third-party servers the same way as the ones you create yourself, and you can still use the client functions you wrote like list_tools() and call_tool(). That's the beauty of MCP, all of the servers expose tools and resources over the same protocol.4. Considerations Before Using a Third-Party Server
Before we go and add a third-party server, we need to consider a few things. Firstly, trust: you'll be running someone else's code, so prefer well-known or officially listed servers over community servers, particularly for enterprise applications. Second, security: if a server needs access to environment variables or configurations, limit its access to the absolute minimum for operation. You don't want to risk leaking information or giving the server permissions to wreak havoc on your systems. Finally, surface area: every tool the server exposes is something the LLM can call, so know what you're adding. For example, if you're using a database MCP, check whether it exposes write operations out of the box - you may not want your LLM or users to have that sort of power!5. Open Library MCP
To lower the stakes a little, we'll be using the Open Library MCP, which wraps the Internet Archive's Open Library API and exposes tools like get_book_by_title, get_authors_by_name, get_book_cover, and get_book_by_id. We don't need an API key for basic use, so it's a good server to start with.6. Accessing the Open Library MCP
In the exercises, this MCP will already be set up for you to use, but if you want to try it out independently, check out the documentation linked. The client code is virtually the same as before: all we need to do is change how the server is started. Rather than executing a Python script to start the server, we use the "open-library-server" command, which is made available on installation. Once the server is running, the Open Library tools are available.7. Using the Open Library MCP
We create and initialize a session, and start calling some tools using the functions we defined earlier! We'll list all of the tools available and print them, and we'll also search for books by title, querying with "Dune".8. Using the Open Library MCP
Here we can see the tools that this server has to offer, and we get structured JSON containing every book with "Dune" in the title.9. Let's practice!
Time to try this out!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.