WEBVTT

00:00.040 --> 00:00.480
Hey there.

00:00.520 --> 00:01.240
Eden here.

00:01.240 --> 00:06.760
And this is a setup video for our boilerplate skeleton for our project.

00:06.760 --> 00:11.440
So we're going to implement now the MCP link chain adapters.

00:11.440 --> 00:13.960
And we're going to learn a bunch on MCP clients.

00:14.280 --> 00:18.080
So in this video we'll create a new project with UV.

00:18.280 --> 00:22.600
We'll create a virtual environment and we'll install our dependencies there.

00:22.920 --> 00:25.560
And then I'm going to commit it to GitHub.

00:25.960 --> 00:32.480
If you want to start from after I'm committing here this code and have the exact code that I have,

00:32.880 --> 00:36.440
then you can simply go and run those commands over here.

00:36.520 --> 00:41.120
So this is going to clone the repository of the course.

00:41.240 --> 00:45.960
It's going to clone the project slash LinkedIn MCP adapters branch.

00:46.280 --> 00:54.280
And after we do that we want to go and CD into the Linkchain MCP adapters where all the code here.

00:54.280 --> 00:58.880
And then we want to check out a commit that I used here.

00:59.120 --> 01:02.680
So this commit has all the code in this video.

01:03.160 --> 01:05.880
And don't worry about copying this command.

01:05.920 --> 01:07.800
You can download the exact command.

01:07.800 --> 01:10.120
I'm going to link it in the video resources.

01:10.400 --> 01:14.680
So this is in case you do not want to start from zero like I'm doing.

01:15.960 --> 01:16.440
All right.

01:16.440 --> 01:24.360
So I'm going to start and go to my GitHub projects and let me clone the repository of the MCP crash

01:24.360 --> 01:24.880
course.

01:24.920 --> 01:28.080
And the URL is going to be listed in the videos resource.

01:28.080 --> 01:29.840
So don't worry about it.

01:30.160 --> 01:30.680
All right.

01:30.680 --> 01:35.120
So I cloned the repository and let's CD into this repo.

01:35.960 --> 01:38.200
And currently I'm on the main branch.

01:38.200 --> 01:39.480
And let me show you it.

01:41.840 --> 01:47.160
And we want to create now a new branch which is going to be for this project.

01:47.280 --> 01:56.320
So let me go write git checkout and I want to write dash dash orphan to make it detached from my original

01:56.320 --> 01:56.840
repo.

01:57.040 --> 02:01.560
And let's call it project slash link chain MCP adapters.

02:02.560 --> 02:06.000
We created the branch and we're on the new branch right now.

02:06.040 --> 02:10.320
Let me show you now the current working directory of the project.

02:10.960 --> 02:15.080
And now it's time to see what files do we have here.

02:15.680 --> 02:17.680
So we see we have a bunch of files.

02:17.680 --> 02:21.360
And you're probably going to see the repo where it's much more organized.

02:21.360 --> 02:23.120
So don't worry about the files here.

02:23.360 --> 02:27.960
What we want to do is to remove those files and start from a clean slate.

02:28.160 --> 02:30.080
So let me go and do that.

02:31.080 --> 02:35.400
So let me write here git rm rf dot.

02:35.400 --> 02:38.760
So this is going to remove all of those files not to track them.

02:38.760 --> 02:40.840
And right now we don't have anything.

02:40.840 --> 02:44.120
And I listed all the files and I don't see anything here.

02:44.120 --> 02:45.720
So this is our starting point.

02:45.720 --> 02:48.920
We have a new branch and we don't have any files here.

02:49.120 --> 02:49.880
Alrighty.

02:49.880 --> 02:53.560
So let's go and initialize our project with UV.

02:53.680 --> 02:59.360
So I wrote uv init, and we have now a bunch of boilerplate files that we can work with.

02:59.560 --> 03:07.200
We can see that the files that were created is a empty readme main.py and a pyproject.toml file.

03:07.400 --> 03:07.960
Cool.

03:07.960 --> 03:14.800
So now I want to open the cursor IDE and this is now our working station.

03:14.800 --> 03:17.280
So let's go and open up terminal.

03:17.600 --> 03:20.200
Let's now create a virtual environment.

03:20.200 --> 03:22.040
I'll write UV Venv.

03:22.960 --> 03:25.160
And now we have a new virtual environment.

03:25.160 --> 03:27.600
You can see we have a venv here.

03:28.320 --> 03:31.080
And let me now source it and activate it.

03:31.080 --> 03:33.120
So I'm going to copy here the script.

03:33.280 --> 03:37.480
And now you can see on the left side we have MCP Crash Course inside parentheses.

03:37.480 --> 03:39.320
So this is our virtual environment.

03:39.520 --> 03:47.800
And by the way if I'm going to exit cursor and open it again then it should automatically activate the

03:47.800 --> 03:48.760
virtual environment.

03:48.760 --> 03:50.640
You can see here on the left side.

03:50.760 --> 03:53.880
And if not you can simply activate it like before.

03:54.400 --> 03:57.760
Anyways, let's go now and let's install our dependencies.

03:58.080 --> 04:01.800
And if I will go to the link Chain adapters repository.

04:02.280 --> 04:06.120
And we can see here in their example we need a bunch of packages.

04:06.480 --> 04:11.880
We need the link chain MCP adapters package lang graph package and link chain OpenAI.

04:12.240 --> 04:18.240
And notice we are not installing explicitly the MCP package because when we install the Lang chain MCP

04:18.280 --> 04:20.800
adapters package, it installs it automatically.

04:21.080 --> 04:21.800
Alrighty.

04:21.840 --> 04:26.920
So let's go and let's copy now those packages and let's add them with UV.

04:30.640 --> 04:36.600
And after we install them let me also add python dot env package to load up environment variables.

04:36.840 --> 04:40.760
And and if it's not already installed as part of their dependencies.

04:41.120 --> 04:46.200
So let me go and add python dotenv and we can see it's already installed.

04:46.640 --> 04:48.480
And let's see the toml file.

04:48.480 --> 04:51.800
And we can see now those are the dependencies that our project needs.

04:53.200 --> 05:00.960
And if we go and head up to UV dot log file here we have the exact version of all the packages in our

05:00.960 --> 05:03.480
virtual environment that we need for the project.

05:03.480 --> 05:05.920
And for example, here I installed LinkedIn core.

05:05.960 --> 05:08.920
Right now the current version is 0.3.5.

05:08.960 --> 05:10.240
One of LinkedIn core.

05:10.560 --> 05:15.120
And when you install it you might have different versions, probably newer ones.

05:15.280 --> 05:18.320
And I'm going to keep this repository and videos up to date.

05:18.320 --> 05:23.320
So unless there are breaking changes I'm going to leave it that if they are I will update this video.

05:23.720 --> 05:28.320
Alright, so let's go to our main.py file and let's go and try to run it.

05:28.600 --> 05:34.640
Let's see, just as a sanity check that everything is working and I'll run it with you've run Main.py

05:34.960 --> 05:37.440
and notice we're inside the virtual environment.

05:37.440 --> 05:39.800
So it's going to contain all of our packages.

05:40.560 --> 05:41.200
All right.

05:41.200 --> 05:42.600
So let's go and run it.

05:42.600 --> 05:44.880
And boom we get the output that we want.

05:45.080 --> 05:46.520
What a beautiful program.

05:46.800 --> 05:47.360
Alrighty.

05:47.360 --> 05:50.040
So I want to make it async.

05:50.240 --> 05:54.840
So I turn this function into a coroutine with the async keyword.

05:55.080 --> 05:59.320
And now in order to run our main file I need to run it with async IO run.

05:59.560 --> 06:01.910
And I love these cursor autocomplete.

06:01.910 --> 06:04.910
I'm simply pressing tab tab tab and it completes me.

06:05.310 --> 06:06.990
And I forgot to import async IO.

06:06.990 --> 06:07.910
So let's do that.

06:08.190 --> 06:10.950
And let's go now and run the code again.

06:12.150 --> 06:13.710
And we can see it's still working.

06:13.710 --> 06:15.350
And this is a good sign.

06:15.630 --> 06:20.990
And I want to create now a dot env file to hold our environment variables.

06:20.990 --> 06:23.750
Because we're going to be using an LM.

06:23.750 --> 06:26.030
So I'm going to use a managed LM.

06:26.430 --> 06:29.870
And let me paste here the values of my environment variables.

06:30.110 --> 06:34.670
And by the way don't worry about the values here of me exposing them.

06:34.710 --> 06:38.630
Um I'm going to revoke it right after I finish exporting this video.

06:39.070 --> 06:44.910
Anyways, I'm using OpenAI right now, but you can use any LM you want that supports function calling.

06:44.910 --> 06:46.550
So you can use anthropic sonnet.

06:46.550 --> 06:47.990
You can use Gemini.

06:48.470 --> 06:50.390
By the way Gemini has a free tier.

06:50.390 --> 06:52.110
So you can use it as well.

06:52.510 --> 06:56.430
And you can use deep sea or any other LM which supports function calling.

06:56.910 --> 07:02.910
So the first environment variable is going to be our OpenAI API key or our API key?

07:03.510 --> 07:07.990
Now the other four API keys you can see here of linked chain.

07:07.990 --> 07:10.510
They are for the link Smith tracing.

07:10.510 --> 07:15.430
So we can actually trace the LLM calls and see exactly what's being sent to the LLM.

07:15.590 --> 07:16.670
And what do we get back.

07:16.670 --> 07:20.070
So I think it's very important to understand it's not a must for you.

07:20.350 --> 07:27.350
So if you do not trace it you simply need to put the link chain tracing V2 equals to false here and

07:27.710 --> 07:28.630
it should work.

07:28.630 --> 07:32.750
And if you are using simply go to the link chain platform and generate the API key.

07:32.750 --> 07:33.390
From there.

07:33.630 --> 07:38.550
Let me know if you wanted to make a video on that, but I'm assuming that you know how to do it anyways.

07:38.550 --> 07:44.470
So I put my API key, I put the endpoint and I call the link chain project MCP test here.

07:44.830 --> 07:52.590
So even though I did revoke now the API keys so you can't actually use them, I want to add here another

07:52.590 --> 07:53.350
file, let's call it.

07:53.350 --> 07:54.150
Gitignore.

07:54.310 --> 07:58.350
And I want to not commit the file to the repository.

07:58.630 --> 08:04.070
So let me just write here And this is simply going to ignore the dot env file.

08:04.070 --> 08:05.990
And you can see it's also grayed out here.

08:06.550 --> 08:08.590
So git is not going to track this file.

08:08.590 --> 08:12.070
And I'm not going to accidentally upload it to my repository.

08:12.670 --> 08:13.110
All right.

08:13.110 --> 08:15.390
So let's go back to the main.py file.

08:15.390 --> 08:20.910
And now we want to load those environment variables and to see that everything is working correctly.

08:20.910 --> 08:22.070
So we can continue.

08:22.070 --> 08:25.950
And to write our actual code and write our first MCP client.

08:26.310 --> 08:29.990
So I'm going to import from env the load inv function.

08:29.990 --> 08:32.630
And I'm going to call it right before my code runs.

08:33.270 --> 08:39.430
And as a sanity check let's go and print the OpenAI API key just to see that we actually loaded it into

08:39.430 --> 08:40.710
our environment variable.

08:42.030 --> 08:44.430
And let's go and try to run it.

08:44.430 --> 08:47.870
And we can see we forgot to import the OS module.

08:47.870 --> 08:49.590
So let's do that and rerun it.

08:49.590 --> 08:55.790
And boom we can see now our API key and our environment is indeed loaded with the correct values.

08:56.350 --> 08:58.390
So that's pretty much it for this video.

08:58.430 --> 08:59.990
We have all the boilerplate code.

08:59.990 --> 09:03.310
And from now on we can go and we can implement our MCP client.

09:03.670 --> 09:08.790
So let me simply go and add everything and let me go and commit it into our repository.

09:10.230 --> 09:13.230
So now we are tracking all the files we created.

09:13.430 --> 09:19.590
And let me show you one of my favorite cursor features where you simply go and generate automatically

09:19.590 --> 09:21.670
with AI the commit message.

09:22.310 --> 09:24.790
And let me go and commit this code here.

09:30.150 --> 09:33.950
And now let me go and push it into the repository.

09:35.030 --> 09:35.270
Oops.

09:35.310 --> 09:37.670
I need to set my upstream repo here.

09:38.390 --> 09:41.510
And now we should see the code available on GitHub.

09:41.510 --> 09:42.750
So let's go to GitHub.

09:42.910 --> 09:48.990
And if I'm going to select now the branch of project slash MCP adapters.

09:49.310 --> 09:50.990
And let's go and click that.

09:51.710 --> 09:55.270
We can see now all the code that we just wrote.

09:55.550 --> 10:00.510
We can see the main.py file, the UV log, the pyproject.toml file and everything.
